-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
68 lines (60 loc) · 2.6 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { Client, ActivityType, GatewayIntentBits, Partials, Collection } = require("discord.js");
const { Guilds, GuildMembers, GuildMessages } = GatewayIntentBits;
const { User, Message, GuildMember, ThreadMember } = Partials;
require("dotenv").config();
var botSettings = require("./settings.json")
const client = new Client({
intents: [Guilds, GuildMembers, GuildMessages],
partials: [User, Message, GuildMember, ThreadMember],
});
const { loadEvents } = require("./handlers/eventHandler");
client.events = new Collection();
client.commands = new Collection();
loadEvents(client);
client.on("messageCreate", (message) => {
if (message.content == "|m") {
message.channel.send("🗿");
}
if (message.content == "stfu bitch") {
message.channel.send("no");
}
});
client.on("guildMemberAdd", async (member) => {
const roleToAdd = await member.guild.roles.cache.get(botSettings.libRole.roleAutoRoleID);
if (botSettings.libRole.roleAutoToggle === true) {
if (botSettings.libRole.roleAutoRoleID = "") return console.log("EHS: [libRole] Failed to assign role due to: Role ID for AutoRole is missing.");
else await member.roles.add(roleToAdd)
.catch(() => { console.log("EHS: [libRole] Failed to assign role due to: Role hierarchy.") });
}
});
client.on("guildMemberAdd", async (member) => {
var banID = await botSettings.libRoot.autoBanRules.indexOf(member.user.username);
if (botSettings.libRoot.autoBanToggle === true) {
if (botSettings.libRoot.autoBanRules.length = 0) return console.log("EHS: [libRoot] Failed to ban member due to: Ruels for AutoBan are missing.");
else if (banID != "-1") {
try { await member.ban({ reason: "You've been banned by The ChaOS 2nd Generation's AutoBan feature." }) }
catch (error) { console.log(`EHS: [libRoot] Failed to ban member due to: ${error}`) }
}
}
});
client
.login(process.env.TOKEN)
.then(() => {
switch (botSettings.libSetup.activityType) {
case "competing":
client.user.setActivity(botSettings.libSetup.activity, { type: ActivityType.Competing });
break;
case "listening":
client.user.setActivity(botSettings.libSetup.activity, { type: ActivityType.Listening });
break;
case "playing":
client.user.setActivity(botSettings.libSetup.activity, { type: ActivityType.Playing });
break;
case "streaming":
client.user.setActivity(botSettings.libSetup.activity, { type: ActivityType.Streaming });
break;
case "watching":
client.user.setActivity(botSettings.libSetup.activity, { type: ActivityType.Watching });
break;
}
});