-
Notifications
You must be signed in to change notification settings - Fork 20
/
deploy.js
58 lines (52 loc) · 1.46 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
55
56
57
58
const { PermissionFlagsBits, SlashCommandBuilder, ContextMenuCommandBuilder } = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v10');
require('dotenv').config();
const deploy = async () => {
const commands = [
new SlashCommandBuilder()
.setName('ping')
.setDescription('Returns the ping.')
.setDMPermission(true),
new SlashCommandBuilder()
.setName('prefix')
.setDescription('Manages the bot prefix.')
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
.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)
.setDMPermission(false),
].map(cmd => cmd.toJSON());
const rest = new REST().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();