-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (39 loc) · 1.29 KB
/
main.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
const { Partials, Client, GatewayIntentBits, Collection, ClientPresence, EmbedBuilder, Colors, ButtonInteraction } = require("discord.js");
const { LoadEvents } = require("./handlers/events");
const { dmJoin } = require("./events/DirMessages/nick");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.Channel,
Partials.GuildMember,
Partials.Message,
Partials.ThreadMember,
Partials.User,
],
});
client.config = require('./Storage/config.json');
client.storage = require("./storage/clientStorage.json");
client.events = new Collection();
client.commands = new Collection();
client.Buttons = new Collection();
LoadEvents(client);
require("./handlers/buttons")(client);
module.exports = { client };
const buttonHandlers = {};
dmJoin(client);
global.handleButton = (id, cb) => {
buttonHandlers[id] = cb;
return { remove: () => delete buttonHandlers[id] };
};
client.on("interactionCreate", i => {
if (i instanceof ButtonInteraction) {
if (buttonHandlers[i.customId]) buttonHandlers[i.customId](i, client);
}
});
client.login(client.config.token);