-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
38 lines (33 loc) · 1.03 KB
/
index.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
import { config } from 'dotenv';
import { Client, GatewayIntentBits } from 'discord.js';
import legacyHandler from './handlers/legacyHandler.js';
import slashHandler from './handlers/slashHandler.js';
import parseMessage from './utils/parseMessage.js';
config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
],
});
client.once('ready', () => {
console.log(`Ready! Logged in as ${client.user.tag}`);
});
client.on('messageCreate', (message) => {
try {
if (message.author.bot) return;
const cmd = parseMessage(message.content);
legacyHandler({ cmd, message, client });
} catch (error) {
console.log('erroro from messageCreate', error);
}
});
client.on('interactionCreate', (interaction) => {
if (!interaction.isCommand()) return;
slashHandler(interaction);
});
client.login(process.env.DISCORD_TOKEN);