-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
37 lines (34 loc) · 1.19 KB
/
main.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
const Discord = require('discord.js');
const commands = require('./commands');
const mentionHandler = require('./handlers/mentionHandler');
require('dotenv').config();
const client = new Discord.Client();
client.on('ready', () => {
for (const command in commands) {
client.api.applications(client.user.id).guilds(process.env.GUILD_ID).commands.post({
data: {name: command, description: commands[command].title}
});
}
client.ws.on('INTERACTION_CREATE', async interaction => {
const command = interaction.data.name.toLowerCase();
if (commands[command]) {
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
embeds: [
{
title: commands[command].title,
description: commands[command].content
}
]
}
}
})
}
});
});
client.on('message', (message) => {
mentionHandler(message);
});
client.login(process.env.TOKEN);