-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
40 lines (33 loc) · 952 Bytes
/
index.ts
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
import { Client, Intents } from 'discord.js';
import { config } from 'dotenv';
import route from './src/router';
const IF = Intents.FLAGS;
const bot = new Client({
intents: [
IF.GUILDS,
IF.DIRECT_MESSAGES,
IF.DIRECT_MESSAGE_TYPING,
IF.GUILD_MESSAGES,
],
});
config();
//Global vars
const CHULS_DISCRIMINATOR = '';
const prefix = '.';
bot.once('ready', () => {
console.log('Buendiaaa');
console.log(prefix);
});
bot.on('disconnect', async () => console.log('Byee'));
//Core Function
bot.on('messageCreate', async msg => {
if (msg.author.bot || !msg.content.startsWith(prefix)) return;
const args = msg.content.substring(prefix.length + 1).split(' ');
const raw_input = msg.content
.substring(prefix.length + 1)
.replace(args[0], '');
console.log('Message: ', args, ' Sent by ', msg.author.username);
//TODO blacklist
route(msg, args[0], args.slice(1), raw_input);
});
bot.login(process.env.BOT_TOKEN);