-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
53 lines (41 loc) · 1.32 KB
/
app.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
const config = require('./config.json');
const { Client, GatewayIntentBits } = require(config.modules[0]);
const { REST } = require(config.modules[1]);
const { Routes } = require(config.modules[2]);
const { SlashCommandBuilder } = require(config.modules[3]);
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
],
});
const commands = [
new SlashCommandBuilder()
.setName('help')
.setDescription('Display help information.')
.toJSON(),
];
const rest = new REST({ version: '10' }).setToken(config.token);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationGuildCommands(config.clientId, config.guildId),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (commandName === 'help') {
await interaction.reply('Here is the help information.'); // Here is the response to "/help".
}
});
client.login(config.token);