This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (34 loc) · 1.46 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
39
40
41
42
43
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
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);
}
// TODO: Add env support (even w/o heroku)
// TODO: Add init command
client.on('message', message => {
// Do nothing if prefix was not used.
if (!message.content.startsWith(process.env.COMMAND_PREFIX) || message.author.bot)
return;
/* TODO: Check using Permisions and/or Roles
* Make PermisionsManager/Checker/Whatever class and do the check inside the commands if it becomes complicated.
* Possibly also check if user is playing among us (Do add toggle function for this)
*/
if (!['Koyniados', 'metalspirit', 'Lyfein'].includes(message.author.username))
return;
const args = message.content.slice(process.env.COMMAND_PREFIX.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
switch (command) {
case 'mute':
client.commands.get('setChannelMuteState').execute(message, true, args);
break;
case 'unmute':
client.commands.get('setChannelMuteState').execute(message, false, args);
break;
}
});
// Investigate ways to abstract this.
client.login(process.env.DISCORD_TOKEN);