-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
60 lines (50 loc) · 1.73 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
// Package imports
const { Client, Intents } = require("discord.js");
// Custom imports
const auth = require("./auth.json");
const commandManager = require("./utilities/command-manager");
const { GUILDS } = require("./utilities/constants");
const { joinSauceEmporiumEvent } = require("./events/joinSauceEmporium");
const { toggleRoleButtonEvent } = require("./events/toggleRoleButton");
const { changeRolesPageEvent } = require("./events/changeRolesPage");
// Client Instance
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS],
});
// On ready
client.once("ready", () => {
console.log("Good Morning!");
// Load commands
commandManager.loadCommands(client);
// Set presence
client.user.setPresence({
activities: [{ type: "LISTENING", name: "the rain" }],
});
});
client.on("interactionCreate", interaction => {
if (interaction.isCommand()) {
commandManager.commandImports
.get(interaction.commandName)
.action(client, interaction);
}
if (interaction.isContextMenu()) {
commandManager.commandImports
.get(interaction.commandName)
.action(client, interaction);
}
if (interaction.isButton()) {
if (interaction.customId.startsWith("toggleRoleButton_")) {
// pass the interaction into a function to sort out the issues
toggleRoleButtonEvent(client, interaction);
} else if (interaction.customId.startsWith("changeRolesPage_")) {
changeRolesPageEvent(client, interaction);
}
}
});
client.on("guildMemberAdd", member => {
if (member.guild.id == GUILDS.YONI) {
joinSauceEmporiumEvent(member);
}
});
// Login
client.login(auth.token);