-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
54 lines (48 loc) · 1.33 KB
/
deploy.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
46
47
48
49
50
51
52
53
54
const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
require('dotenv').config();
const deploy = async () => {
const commands = [
new SlashCommandBuilder()
.setName('ping')
.setDescription('Returns the ping.'),
new SlashCommandBuilder()
.setName('prefix')
.setDescription('Manages the bot prefix.')
.addSubcommand((sc) =>
sc
.setName('view')
.setDescription('Views the current prefix.'),
)
.addSubcommand((sc) =>
sc
.setName('set')
.setDescription('Sets the prefix to a new one.')
.addStringOption((string) =>
string
.setName('value')
.setDescription('The new prefix.')
.setRequired(true),
),
),
new ContextMenuCommandBuilder()
.setName('User Info')
.setType(2),
].map(cmd => cmd.toJSON());
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
try {
const clientId = process.env.CLIENT_ID;
console.log('Started refreshing Slash Commands and Context Menus...');
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
).then(() => {
console.log('Slash Commands and Context Menus have now been deployed.');
});
}
catch (e) {
console.error(e);
}
};
deploy();