Skip to content

Commit 0cf6d4c

Browse files
committed
Initial commit
0 parents  commit 0cf6d4c

File tree

11 files changed

+160
-0
lines changed

11 files changed

+160
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DISCORD_APP_ID=
2+
DISCORD_PUBLIC_KEY=
3+
DISCORD_BOT_TOKEN=
4+
DEBUG=false

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
env: {
3+
commonjs: true,
4+
es6: true,
5+
node: true
6+
},
7+
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
8+
globals: {},
9+
plugins: 'prettier',
10+
parserOptions: {
11+
ecmaVersion: 6,
12+
sourceType: 'module'
13+
},
14+
rules: {
15+
'prettier/prettier': 'warn',
16+
'no-cond-assign': [2, 'except-parens'],
17+
'no-unused-vars': 0,
18+
'no-empty': ['error', { allowEmptyCatch: true }],
19+
'prefer-const': ['warn', { destructuring: 'all' }],
20+
'spaced-comment': 'warn'
21+
}
22+
};

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Packages
2+
node_modules/
3+
yarn.lock
4+
package_lock.json
5+
6+
# Log files
7+
logs/
8+
*.log
9+
10+
# Miscellaneous
11+
.tmp/
12+
.vscode/**/*
13+
!.vscode/extensions.json
14+
.env

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"trailingComma": "none",
7+
"printWidth": 120
8+
}

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"deepscan.vscode-deepscan",
4+
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode"
6+
]
7+
}

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# slash-create-template
2+
This templates helps you in creating slash commands from a webserver.
3+
4+
## Installation
5+
1. Install dependencies
6+
```sh
7+
npm i -g yarn # if you don't have it already
8+
yarn install
9+
```
10+
2. Copy over `.env.example` into `.env` and fill in the variables.
11+
3. Create any more commands you want.
12+
4. `yarn start`
13+
14+
### Using PM2
15+
1. `npm i -g pm2`
16+
2. Follow the first, second and third step above
17+
3. `pm2 start pm2.json`
18+
4. (recommended) `pm2 dump`

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "slash-create-template",
3+
"version": "1.0.0",
4+
"description": "A template for slash-create",
5+
"main": "src/index.js",
6+
"scripts": {
7+
"start": "node src/index.js"
8+
},
9+
"dependencies": {
10+
"cat-loggr": "^1.1.0",
11+
"dotenv": "^8.2.0",
12+
"fastify": "^3.9.2",
13+
"slash-create": "^1.1.0"
14+
},
15+
"devDependencies": {
16+
"eslint": "^7.15.0",
17+
"eslint-config-prettier": "^7.0.0",
18+
"eslint-plugin-prettier": "^3.3.0",
19+
"prettier": "^2.2.1"
20+
}
21+
}

pm2.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"apps": [
3+
{
4+
"name": "slash-commands",
5+
"script": "node",
6+
"args": "src/index.js"
7+
}
8+
]
9+
}

src/commands/hello.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { SlashCommand, CommandOptionType } = require('slash-create');
2+
3+
module.exports = class HelloCommand extends SlashCommand {
4+
constructor(creator) {
5+
super(creator, {
6+
name: 'hello',
7+
description: 'Says hello to you.',
8+
options: [{
9+
type: CommandOptionType.STRING,
10+
name: 'food',
11+
description: 'What food do you like?'
12+
}]
13+
});
14+
}
15+
16+
async run(ctx) {
17+
return ctx.options.food ? `You like ${ctx.options.food}? Nice!` : `Hello, ${ctx.member.displayName}!`;
18+
}
19+
}

0 commit comments

Comments
 (0)