-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-commands.ts
More file actions
47 lines (43 loc) · 1.27 KB
/
setup-commands.ts
File metadata and controls
47 lines (43 loc) · 1.27 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
const { SlashCommandBuilder } = require("@discordjs/builders");
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const yargs = require("yargs");
const options = yargs
.usage("Usage: -t <token> -a <application_id> -g <guild_id>")
.option("t", {
alias: "token",
describe: "Discord bot token",
type: "string",
demandOption: true,
})
.option("a", {
alias: "application_id",
describe: "Discord application/client id",
type: "string",
demandOption: true,
})
.option("g", {
alias: "guild_id",
describe: "Discord guild/server id",
type: "string",
demandOption: true,
}).argv;
// Register the slash commands available to users
const commands = [
new SlashCommandBuilder()
.setName("verify")
.setDescription(
"Grants the Maintainer role for maintainers of repositories listed on opensourcehub.io"
),
].map((command) => command.toJSON());
const rest = new REST({ version: "9" }).setToken(options.token);
// Upload the commands to the Discord server
rest
.put(
Routes.applicationGuildCommands(options.application_id, options.guild_id),
{
body: commands,
}
)
.then(() => console.log("Successfully registered application commands."))
.catch(console.error);