-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
145 lines (126 loc) · 3.84 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
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
137
138
139
140
141
142
143
144
145
const Discord = require("discord.js");
require("dotenv").config();
const command = require("./utils/command");
const rolesMessage = require("./utils/roles-message");
const welcomeMessageListener = require("./listeners/welcome");
const rolesMessageListener = require("./listeners/reactions");
const membersCountListener = require("./listeners/member-count");
const deletedMessageListener = require("./listeners/delete-message");
const privateMessageListener = require("./listeners/private-message");
const { rolesChannelID, rolesMessageID } = require("./config.json");
const mongo = require("./database/mongo");
const client = new Discord.Client({
partials: ["MESSAGE", "REACTION", "CHANNEL"],
});
client.on("ready", async () => {
await mongo().then((mongoose) => {
try {
console.log("Connected to Mongo!");
} finally {
mongoose.connection.close();
console.log("disconnected from Mongo!");
}
});
console.log("\nMS CLUBS Bot is ready\n\n");
// LISTENERS
welcomeMessageListener(client);
deletedMessageListener(client);
rolesMessageListener(client);
membersCountListener(client);
privateMessageListener(client, "upcoming dates", "Checkout https://make.sc/academic-calendar");
rolesPrompt = `React with one of the emojis to get a role
📣 | News & Announcements Notifications
♟️ | Chess Club
🏹 | Minecraft Club
🎲 | DnD Club`;
rolesMessage(client, rolesChannelID, rolesMessageID, rolesPrompt, ["📣", "♟️", "🏹", "🎲"]);
// COMMANDS
command(client, ["si", "servers", "serverInfo"], (message) => {
client.guilds.cache.forEach((guild) => {
// console.log(guild);
const { name, region, memberCount, owner, afkTimeout } = guild;
const icon = guild.iconURL();
const embed = new Discord.MessageEmbed()
.setTitle(`"${name}" Server Info`)
.setThumbnail(icon)
.setFooter(`Owner: ${owner.user.tag}`)
.addFields(
{
name: "Region",
value: region,
},
{
name: "Members",
value: memberCount,
},
{
name: "AFK Timeout",
value: afkTimeout / 60,
}
);
message.channel.send(embed);
});
});
command(client, ["cc", "clearchannel"], (message) => {
if (message.member.hasPermission("ADMINISTRATOR")) {
message.channel.messages.fetch().then((results) => {
message.channel.bulkDelete(results);
// console.log("All Messaged Deleted: \n", results)
});
}
});
command(client, "status", (message) => {
const content = message.content.replace("ms!status ", "");
client.user.setPresence({
activity: {
name: content,
type: 0,
},
});
});
command(client, "embed", (message) => {
const logo = "";
const embed = new Discord.MessageEmbed()
.setTitle("Make School Courses")
.setURL("https://makeschool.com/")
.setAuthor(message.author.username)
.setImage(logo)
.setThumbnail(logo)
.setFooter("This is a footer", logo)
.setColor("#00AAFF")
.addFields(
{
name: "CS",
value: "https://make.sc/CS1.0",
inline: true,
},
{
name: "DS",
value: "https://make.sc/DS1.0",
inline: true,
},
{
name: "BEW",
value: "https://make.sc/BEW1.0",
inline: true,
},
{
name: "SPD",
value: "https://make.sc/SPD1.0",
inline: true,
},
{
name: "MOB",
value: "https://make.sc/MOB1.0",
inline: true,
},
{
name: "FEW",
value: "https://make.sc/FEW1.0",
inline: true,
}
);
message.channel.send(embed);
});
});
client.login(process.env.BOT_TOKEN);