This repository has been archived by the owner on Sep 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (54 loc) · 1.59 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const Discord = require("discord.js");
const bot = new Discord.Client();
require("dotenv-flow").config();
const { prefixes } = require("./config.json");
const fs = require("fs");
bot.commands = new Discord.Collection();
const commandFiles = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
bot.once("ready", () => {
console.log("Bot is online biatch!");
// to display prefix of bot to users
bot.user.setPresence({
activity: {
type: "LISTENING",
name: prefixes.map((prefix) => prefix).join(" | "),
},
});
});
bot.on("message", (message) => {
// check for any one of the bot prefixes
let isBotCalled = false;
prefixes.forEach((prefix) => {
if (message.content.startsWith(prefix)) return (isBotCalled = true);
});
if (!isBotCalled || message.author.bot) return;
const args = message.content.slice(prefixes.length).split(/ +/);
const command = args.shift().toLowerCase();
switch (command) {
case "ping":
bot.commands.get("ping").execute(message, args);
break;
case "timer":
case "t":
bot.commands.get("timer").execute(message, args);
break;
case "mute":
case "m":
bot.commands.get("mute").execute(message, args);
break;
case "unmute":
case "u":
bot.commands.get("unmute").execute(message, args);
break;
default:
message.channel.send("Yo Bitch, I don't recognize that command.");
break;
}
});
bot.login(process.env.TOKEN);