-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
130 lines (107 loc) · 3.16 KB
/
index.js
File metadata and controls
130 lines (107 loc) · 3.16 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
require("dotenv").config();
const {
Client,
GatewayIntentBits,
Partials,
Collection,
} = require("discord.js");
const bot = new Client({
partials: [
Partials.User,
Partials.Reaction,
Partials.Message,
Partials.Channel,
Partials.GuildMember,
],
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
bot.commands = new Collection();
const botCommands = require("./commands/");
const utils = require("./utils/utils.js");
const sources = require("./sources/index.js");
const gameChannelNames = ["guess-the-game", "wordle", "octordle"];
const marbles = require("./components/Marbles.js");
const Marbles = new marbles.Marbles();
Object.keys(botCommands).map((key) => {
bot.commands.set(botCommands[key].name, botCommands[key]);
});
const TOKEN = process.env.TOKEN;
const TEST_MODE = process.env.TEST_MODE;
const TESTER_ID = process.env.TESTER_ID;
bot
.login(TOKEN)
.catch((err) => console.log("Couldn't login. Wrong token?" + "\n" + err));
bot.on("ready", () => {
console.info(`Logged in as ${bot.user.tag}!`);
});
bot.on("messageCreate", async (msg) => {
if (TEST_MODE && msg.author.id !== TESTER_ID) return;
const bannedWords = process.env.BANNED_WORDS.split(", ");
if (msg.author.bot) {
return;
}
const bannedWordCheck = utils.checkForBannedWords(msg.content, bannedWords);
let args;
let command;
let users;
if (msg.content.toLowerCase().includes("apple")) {
msg.react("🍏");
}
if (bannedWordCheck) {
const possibleReplies = sources.replies.bannedWords;
const reply = utils.getRandomEntryFromArray(
possibleReplies,
possibleReplies.length
);
msg.delete();
return msg.channel.send(reply);
}
const channelName = msg.channel.name;
const isGameChannel = gameChannelNames.includes(channelName);
if (isGameChannel) {
Marbles.determineGameChannel(channelName, msg);
}
if (msg.content.toLowerCase().includes("marble1")) {
const emoji = utils.getMarbleEmojiFromColor("blue");
msg.react(emoji);
}
if (msg.content.toLowerCase().includes("marble2")) {
const emoji = utils.getMarbleEmojiFromColor("green");
msg.react(emoji);
}
if (msg.content.toLowerCase().includes("marble3")) {
const emoji = utils.getMarbleEmojiFromColor("orange");
msg.react(emoji);
}
if (msg.content.toLowerCase().includes("marble4")) {
const emoji = utils.getMarbleEmojiFromColor("red");
msg.react(emoji);
}
if (msg.content.toLowerCase().includes("marble5")) {
const emoji = utils.getMarbleEmojiFromColor("yellow");
msg.react(emoji).catch((error) => console.error(error));
}
if (msg.content.startsWith("!")) {
args = msg.content.split(" ");
command = args[0].toLowerCase().toString();
users = bot.users;
}
if (args === undefined) {
args = msg.content;
command = args.toLowerCase().replace(/\s/g, "").toString();
}
if (!bot.commands.has(command)) {
return;
}
try {
bot.commands.get(command).execute(msg, args, bot);
} catch (error) {
console.error(error);
msg.reply("Tell the Cap'n me peg leg is shattered!");
}
});