-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.js
More file actions
73 lines (64 loc) · 2.31 KB
/
commands.js
File metadata and controls
73 lines (64 loc) · 2.31 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { discord } = require('config');
const join = new SlashCommandBuilder()
.setName('join')
.setDescription('Join something')
.addSubcommand((sc) =>
sc
.setName('group')
.addMentionableOption((m) => m.setName('role').setDescription('The role to add').setRequired(true))
.setDescription('The Role to join usually prefixed with g:')
)
.toJSON();
const version = new SlashCommandBuilder().setName('version').setDescription('Returns the version of the bot').toJSON();
const change = new SlashCommandBuilder()
.setName('change')
.setDescription('Change settings for the server or bot')
.addSubcommand((sc) => sc.setName('region').setDescription('Change the server region'))
.toJSON();
const list = new SlashCommandBuilder()
.setName('list')
.setDescription('List something')
.addSubcommand((sc) => sc.setName('groups').setDescription('List joinable groups'))
.toJSON();
const leave = new SlashCommandBuilder()
.setName('leave')
.setDescription('Leave something')
.addSubcommand((sc) =>
sc
.setName('group')
.setDescription('Leave a group')
.addMentionableOption((m) => m.setName('role').setDescription('The role to leave').setRequired(true))
)
.toJSON();
const create = new SlashCommandBuilder()
.setName('create')
.setDescription('Create something')
.addSubcommand((sc) =>
sc
.setName('group')
.setDescription('Create a group')
.addStringOption((o) => o.setName('name').setDescription('Name of the group').setRequired(true))
)
.toJSON();
const commands = [create, join, version, change, list, leave];
const rest = new REST({ version: '9' }).setToken(discord.token);
const update = () => {
return rest
.put(Routes.applicationGuildCommands(discord.clientId, discord.guildId), { body: commands })
.then(() => {
console.log('Successfully registered application commands.');
})
.catch(console.error);
};
const del = () => {
return rest
.put(Routes.applicationGuildCommands(discord.clientId, discord.guildId), { body: [] })
.then(() => {
console.log('Successfully registered application commands.');
})
.catch(console.error);
};
update();