-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathdeploy-command.js
More file actions
72 lines (67 loc) · 1.87 KB
/
deploy-command.js
File metadata and controls
72 lines (67 loc) · 1.87 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
const { REST, Routes, ApplicationCommandOptionType } = require('discord.js');
const faqs = require('./faqs.json');
require('dotenv').config();
const commands = [
{
name: 'faq',
description: 'Get an answer to a GSSoC FAQ',
options: [
{
name: 'question',
description: 'Your question',
type: ApplicationCommandOptionType.String,
required: true,
autocomplete: true
}
]
},
{
name: 'project',
description: 'Get details about a GSSoC project',
options: [
{
name: 'project-name',
description: 'Name of the project',
type: ApplicationCommandOptionType.String,
required: true,
autocomplete: true
},
{
name: 'phase',
description: 'Filter projects by GSSoC phase',
type: ApplicationCommandOptionType.String,
required: false,
choices: [
{ name: 'Phase 1', value: 'phase1' },
{ name: 'Phase 2', value: 'phase2' }
]
},
{
name: 'question',
description: 'Optional follow-up question (e.g. "guide to contribute")',
type: ApplicationCommandOptionType.String,
required: false
}
]
},
{
name: 'fun',
description: 'Get a fun nerdy joke or fact'
},
];
const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
(async () => {
try {
console.log('Registering slash command...');
await rest.put(
// Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID), // for Guild commands
Routes.applicationCommands(process.env.CLIENT_ID),
{ body: commands }
);
console.log('✅ Slash command registered.');
} catch (err) {
console.error(err);
}
})();
// const data = await rest.get(Routes.applicationCommands(process.env.CLIENT_ID));
// console.log("Registered commands:", data.map(cmd => cmd.name));