forked from discord/discord-example-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.js
45 lines (38 loc) · 980 Bytes
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import 'dotenv/config';
import { getRPSChoices } from './game.js';
import { capitalize, InstallGlobalCommands } from './utils.js';
// Get the game choices from game.js
function createCommandChoices() {
const choices = getRPSChoices();
const commandChoices = [];
for (let choice of choices) {
commandChoices.push({
name: capitalize(choice),
value: choice.toLowerCase(),
});
}
return commandChoices;
}
// Simple test command
const TEST_COMMAND = {
name: 'test',
description: 'Basic command',
type: 1,
};
// Command containing options
const CHALLENGE_COMMAND = {
name: 'challenge',
description: 'Challenge to a match of rock paper scissors',
options: [
{
type: 3,
name: 'object',
description: 'Pick your object',
required: true,
choices: createCommandChoices(),
},
],
type: 1,
};
const ALL_COMMANDS = [TEST_COMMAND, CHALLENGE_COMMAND];
InstallGlobalCommands(process.env.APP_ID, ALL_COMMANDS);