-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
101 lines (90 loc) · 3.37 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
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
const Discord = require("discord.js");
const { discord, messages } = require("./utils/horizonUtils");
const { voiceRole } = require("./include/voice");
require("./server");
const bot = new Discord.Client({
partials: ["MESSAGE", "CHANNEL", "REACTION"],
});
bot.on("ready", async () => {
await bot.user.setPresence({
activity: {
name: `Gerenciando cargos do servidor!!`,
type: 1,
url: "https://twitch.tv/bravanzin",
},
});
console.log("[Bot] Connected");
});
//* add voice role
bot.on("voiceStateUpdate", (oldState, newState) => {
voiceRole(oldState, newState);
});
//* reaction add role check
bot.on("messageReactionAdd", async (reaction, user) => {
const id = reaction.message.id;
const roles = reaction.message.guild.roles.cache;
const members = reaction.message.guild.members.cache;
if (reaction.partial) await reaction.fetch();
//* "Horizon Member" role
if (id === messages.rules) {
const role = roles.find((role) => role.name === "Horizon Member");
const level = roles.find((roles) => roles.name === "level 1");
members.get(user.id).roles.add(level);
members.get(user.id).roles.add(role);
}
//* "Tasks Verified" role
if (id === messages.tasks) {
const role = roles.find((role) => role.name === "Tasks Verified");
members.get(user.id).roles.add(role);
}
//* "Valorant" role
if (id === messages.games.valorant) {
const role = roles.find((role) => role.name === "Valorant");
members.get(user.id).roles.add(role);
}
//* "League of Legends" role
if (id === messages.games.leagueoflegends) {
const role = roles.find((role) => role.name === "League of Legends");
members.get(user.id).roles.add(role);
}
//* "Ragnarok" role
if (id === messages.games.ragnarok) {
const role = roles.find((role) => role.name === "Ragnarok");
members.get(user.id).roles.add(role);
}
});
//* reaction remove role check
bot.on("messageReactionRemove", async (reaction, user) => {
const id = reaction.message.id;
const roles = reaction.message.guild.roles.cache;
const members = reaction.message.guild.members.cache;
if (reaction.partial) await reaction.fetch();
//* "Horizon Member" role
if (reaction.message.id === messages.rules) {
const role = roles.find((role) => role.name === "Horizon Member");
const level = roles.find((roles) => roles.name === "level 1");
members.get(user.id).roles.remove(role);
members.get(user.id).roles.remove(level);
}
//* "Tasks Verified" role
if (id === messages.tasks) {
const role = roles.find((role) => role.name === "Tasks Verified");
members.get(user.id).roles.remove(role);
}
//* "Valorant" role
if (id === messages.games.valorant) {
const role = roles.find((role) => role.name === "Valorant");
members.get(user.id).roles.remove(role);
}
//* "League of Legends" role
if (id === messages.games.leagueoflegends) {
const role = roles.find((role) => role.name === "League of Legends");
members.get(user.id).roles.remove(role);
}
//* "Ragnarok" role
if (id === messages.games.ragnarok) {
const role = roles.find((role) => role.name === "Ragnarok");
members.get(user.id).roles.remove(role);
}
});
bot.login(discord);