-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbot.js
More file actions
40 lines (30 loc) · 1.29 KB
/
bot.js
File metadata and controls
40 lines (30 loc) · 1.29 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
const Discord = require('discord.js')
const client = new Discord.Client();
const db = require('quick.db')
client.on('ready', () => {
console.log(`Logged on ${client.user.tag}`)
})
client.commands= new Discord.Collection();
const { join } = require('path');
const { readdirSync } = require('fs');
const commandFiles = readdirSync(join(__dirname, "commands")).filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(join(__dirname, "commands", `${file}`));
client.commands.set(command.name , command);
}
const { token , prefix } = require('./config.json')
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === 'dm') return;
if(message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!client.commands.has(command)) return;
try {
client.commands.get(command).run(client, message, args, db, prefix);
} catch (error){
console.error(error);
}
}
})
client.login(token)