mirror of
https://github.com/sern-handler/website
synced 2026-06-06 01:16:47 +00:00
start on overview
This commit is contained in:
@@ -18,10 +18,6 @@ Alright, enough rambling. Let's open up a terminal (your favorite thing I know..
|
||||
yarn add dotenv
|
||||
```
|
||||
This command will add dotenv to the dependencies. Awesome!
|
||||
Let's now go to our `index.js` file and add a new import:
|
||||
```js
|
||||
import 'dotenv/config'
|
||||
```
|
||||
And create a blank `.env` file in the root of your project directory (the directory where, for example, your `package.json` file is)
|
||||
|
||||
```
|
||||
@@ -92,4 +88,4 @@ And your bot should start up in no time! Congrats!
|
||||
---
|
||||
Written by [Sr Izan](../intro/who-are-we#ethan)
|
||||
Get the [source code](https://github.com/sern-handler/tutorial-bot/tree/setting-up-bot/creating-discord-app)!
|
||||
<GuideFeedback />
|
||||
<GuideFeedback />
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: commands
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Commands
|
||||
|
||||
Every sern command is located in the commands directory.
|
||||
|
||||
:::caution
|
||||
Any command outside the specificed directory from `Sern.init` will be ignored!
|
||||
:::
|
||||
|
||||
### Look at ping.js (go into your tutorial rn)
|
||||
|
||||
Please soak in all the comments I wrote for what each field will do. We will make a brand new command.
|
||||
|
||||
:::tip
|
||||
The name of your command will be the name of your file. This is the ping command.
|
||||
:::
|
||||
|
||||
We can activate this command by running `!ping` or `/ping`
|
||||
|
||||
Each command will follow this similar structure.
|
||||
In this tutorial, we'll be making tictactoe!
|
||||
|
||||
### New command
|
||||
- Make a new file
|
||||
- Call it **tictactoe.js**
|
||||
- import `CommandType` and `commandModule` from `@sern/handler`
|
||||
- export this command under the [**default**](https://www.geeksforgeeks.org/what-is-export-default-in-javascript) export
|
||||
- give it the type `CommandType.Slash`
|
||||
- Give it a description.
|
||||
#### Halfway
|
||||
This is what your command should look like rn
|
||||
|
||||
```js title=./commands/tictactoe.js
|
||||
export default commandModule({
|
||||
type: CommandType.Slash,
|
||||
description: "I do tictactoe."
|
||||
})
|
||||
```
|
||||
- Give it a function to execute.
|
||||
- For now, let's tell the command to execute a reply like "in progress"
|
||||
- run `sern commands publish`
|
||||
- Your command should be usable on discord now!
|
||||
|
||||
### Result
|
||||
Your command should now look something along the lines of this:
|
||||
```js title=./commands/tictactoe.js
|
||||
export default commandModule({
|
||||
type: CommandType.Slash,
|
||||
description: "I do tictactoe."
|
||||
execute: (ctx) => {
|
||||
ctx.reply("Pwease wait. dis command in pwogwess");
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
7
docs/tutorial/en/05-overview/plugins.md
Normal file
7
docs/tutorial/en/05-overview/plugins.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: plugins?
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
---
|
||||
title: index
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# start
|
||||
|
||||
## initiate
|
||||
We start at the humble index.js. This is where this bot will start. Notice the Sern.init, hmm... I wonder what that does. (it initiates sern)
|
||||
A few options are availible, which are conviently labeled already. Make sure to take a look at them.
|
||||
A few options are availible, which are **conveniently labeled already**. Make sure to glance here.
|
||||
|
||||
## dependencies
|
||||
This requires a little more explaning. Basically in `makeDependencies`, we initiate a container of services and structures. sern and you, the developer will use these structures. In the [template](../04-setting-up-bot/create-bot) you have now, we only initiate the client, which is necessary for the handler to run.
|
||||
This requires a little more explaning. In `makeDependencies`, add necessary objects to run your application. you and sern, will use these structures. In the [template](../04-setting-up-bot/create-bot) you have now, we only initiate the client, which is necessary for the handler to run.
|
||||
|
||||
```js
|
||||
await makeDependencies({
|
||||
build: (root) => root.add({
|
||||
'@sern/client': single(() => client) // we register our client into sern
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user