-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbot.js
More file actions
66 lines (50 loc) · 1.84 KB
/
bot.js
File metadata and controls
66 lines (50 loc) · 1.84 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//discord.js required for bot to function
const { Client, Intents, Message, MessageEmbed } = require('discord.js');
const Discord = require('discord.js');
const client = new Client({intents : [Intents.FLAGS.GUILD_MESSAGES , Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS ,
Intents.FLAGS.GUILDS , Intents.FLAGS.GUILD_MEMBERS , Intents.FLAGS.DIRECT_MESSAGE_REACTIONS ,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS]});
client.config = require("./config");
const welcome = require("./welcome");
const fs = require('fs');
//bot prefix for commands
const prefix = "-";
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.on('ready', () => {
console.log('Sado is ready to make dosas!');
welcome(client);
});
client.on('message', message => {
switch(message.content.toUpperCase()) {
case '-RESET':
resetBot(message.channel);
break;
// ... other commands
}
});
client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift();
if(command === 'sado'){
client.commands.get('sado').execute(message, args);
}
if(command === 'pain'){
client.commands.get('pain').execute(message, args, client);
}
if(command === 'genshit'){
client.commands.get('genshit').execute(message, args, client);
}
});
function resetBot(channel) {
// send channel a message that you're resetting bot [optional]
msg => client.destroy()
.then(() => client.login(client.config.app.token));
channel.send('Reset!')
}
client.login(client.config.token);