-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
136 lines (116 loc) · 4.96 KB
/
index.js
File metadata and controls
136 lines (116 loc) · 4.96 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
131
132
133
134
135
136
if (process.versions.node.split(".")[0] < 17) {
console.error(`You are currently running Node.js version ${process.version}.
Multitool requires Node.js version 17 or above.
Now exiting.`);
process.exit(1);
}
const Eris = require("eris");
const path = require("path");
const logger = require("./utils/logging.js");
const config = require("./utils/config.js");
const fs = require("fs");
require('dotenv').config();
console.log(`
BBBBBB #BBB########BBB# BBBBBB
&&&&&&&�P&&&GPPPPPPPPPPPPPPG&&&P55555#&&&&&&&&
BPPPPPPPPPYYYYYYPPPGGGP55PPPP55PGGGPPPYYYYYYPPPPPPPPPB
#BB5??JJJYPP5YYJ???YYYPGGPPPP55PPPPGGPYYY???JYY5PPYJJJ??5BB#
G5PJ!!7?7JP55JJJ???YYYPGGGGGPPPPGGGGGPYYY???JJJ55PJ7?7!!JP5G
GPPJ!!?JJJYYJ7!7PPPPPPGGGPPPPGGPPPPGGGPPPPPP7!7JYYJJJ?!!JPPG
GPPY???77?555YYY???5PPGGGPPPPGGPPPPGGGPP5???YYY555?77???YPPG
BGG5YYJ??JPPPPP57775PPGGGPPPPGGPPPPGGGPP57775PPPPPJ??JYY5GGB
BPPPPPP555PP5?7?5PPGGGGGGPPPPGGGGGGPP5?7?5PP555PPPPPPB
B555PPG&#&&&#JJJ???5PPPPPY??YPPPPP5???JJJ#&&&#&GPP555B
&#&BGGGGG# &&#PPPJJJ5555Y5?77?5Y5555JJJPPP#&& #GGGGGB&#&
GP5# &PPP BGBYJJ?77777777?JJYBGB PPP& #5PG
G55B #PPG&&& &&&GPGPPPPPPPPPPGPG&&& &&&GPP# B55G
BGGB##& &GGG### BGGGGPB##BPGGGGB ###GGG& &##BGGB
BPPB &PPP GPP555B B555PPG PPP& BPPB
&&B55G &555 P55B&& &&B55P 555& G55B&&
#GGB &GGB BGG& &GGB BGG& BGG#
`);
const commands = [];
const autoresponse = [];
// Replace TOKEN with your bot account's token
const bot = new Eris.CommandClient(process.env.DISCORD_TOKEN, {intents: ["all"], maxShards: "auto"},{
description: "Multitool: A multipurpose discord bot",
owner: process.env.OWNER_ID,
prefix: config.getConfig().bot.prefix
});
function init() {
registerCommands();
registerResponses();
}
function registerCommands() {
const timer = Date.now();
commands.splice(0,commands.length); // Refresh commands
const commandsPath = path.join(__dirname, 'commands'); // Get the path of the commands folder
// const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); // Get every file that ends with JS
fs.readdirSync(commandsPath).forEach(dir => {
fs.readdir(path.join(commandsPath + `/${dir}`), (err, files) => {
commandFiles = fs.readdirSync(path.join(commandsPath + `/${dir}`)).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(path.join(commandsPath + `/${dir}`), file);
const command = require(filePath);
bot.unregisterCommand(command[0]);
bot.registerCommand(command[0], command[1], command[2])
}
});
});
logger.info(`Commands registed in ${(Date.now()-timer)} ms`);
}
function registerResponses() {
const timer = Date.now();
autoresponse.splice(0,commands.length); // Refresh responses
const arPath = path.join(__dirname, 'autoresponder'); // Get the path of the commands folder
const arFiles = fs.readdirSync(arPath).filter(file => file.endsWith('.js')); // Get every file that ends with JS
for (const file of arFiles) {
const filePath = path.join(arPath, file);
const ar = require(filePath);
autoresponse.push([ar.regex, ar.response]);
}
logger.info(`Responses registed in ${(Date.now()-timer)}ms`);
}
bot.on("ready", () => { // When the bot is ready
init();
bot.editStatus("online", {name: "everyone's every move", type: 3, link: "https://discord.gg/n8se25bGCx"});
logger.info("Bot is on");
});
bot.on("error", (err) => {
logger.error(err);
});
bot.on("messageCreate", async (msg) => { // When a message is created
if (msg.author.id === bot.user.id) return; // don't want an infinite loop
for (let i = 0; i < autoresponse.length; i++) {
const data = autoresponse[i];
if (data[0].test(msg.content)) {
bot.createMessage(msg.channel.id, data[1]);
return;
}
}
});
bot.on("messageReactionAdd", async (message, emoji, reactor) => {
let rr = config.getModule("rr");
for (let i = 0; i < rr.length; i++) {
const data = rr[i];
if (data.msg == message.id) {
if (data.emoji == emoji.id) {
reactor.addRole(data.role, "Reacted to reaction role");
}
}
}
})
bot.on("messageReactionRemove", async (message, emoji, userid) => {
let rr = config.getModule("rr");
for (let i = 0; i < rr.length; i++) {
const data = rr[i];
if (data.msg == message.id) {
if (data.emoji == emoji.id) {
bot.guilds.get(message.guildID).removeMemberRole(userid, data.role, "Unreacted from reaction role");
}
}
}
})
bot.on("shardReady", async(id) => {logger.info(`Shard #${id} is now ready.`)})
bot.on("shardDisconnect", async(id) => {logger.warn(`Shard #${id} has disconnected.`)})
bot.connect(); // Get the bot to connect to Discord