-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·184 lines (158 loc) · 5.36 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
const { deleteOld, registerCommands } = require("./deploy-commands.js");
const { consoleError, consoleMessage } = require("./log.js")
const fs = require("node:fs");
const path = require("node:path");
const {
Client,
Collection,
EmbedBuilder,
Partials,
IntentsBitField,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Events,
} = require("discord.js");
// const { Player } = require("discord-player");
const Config = require("./config.json");
const { DiscordTogether } = require("discord-together");
const express = require("express");
//express server for uptime robot
const app = express();
const port = 3333;
app.get("/", (req, res) => {
res.send("Bot is online!");
consoleMessage("status page visited", "index.express");
});
app.listen(port, () => {
consoleMessage(`Status server is running on port ${port}`, "index.express");
});
//end
if (Config.DELETE_OLD) deleteOld();
registerCommands();
const Intents = new IntentsBitField([
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildVoiceStates,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.GuildEmojisAndStickers,
IntentsBitField.Flags.GuildModeration,
IntentsBitField.Flags.GuildWebhooks,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.DirectMessages,
IntentsBitField.Flags.DirectMessageReactions,
]);
const client = new Client({
intents: Intents,
partials: [Partials.Channel],
});
// const player = Player.singleton(client);
// player.events.on("playerStart", (queue, track) => {
// const embed = new EmbedBuilder()
// .setTitle("Play song")
// .setDescription(
// `Now playing **${
// track.title
// }** which was requested by **${queue.metadata.user.toString()}**!`
// )
// .setColor("Green")
// .setAuthor({ name: queue.metadata.user.tag })
// .setThumbnail(queue.metadata.user.displayAvatarURL({ dynamic: true }))
// .setTimestamp()
// .setFooter({
// text: "Music System • Alienbot",
// iconURL: "https://thealiendoctor.com/img/alienbot/face-64x64.png",
// });
// const row = new ActionRowBuilder().addComponents(
// new ButtonBuilder()
// .setCustomId("stopButton")
// .setStyle(ButtonStyle.Primary)
// .setLabel("Stop"),
// new ButtonBuilder()
// .setCustomId("skipButton")
// .setStyle(ButtonStyle.Primary)
// .setLabel("Skip"),
// new ButtonBuilder()
// .setCustomId("pauseButton")
// .setStyle(ButtonStyle.Primary)
// .setLabel("Pause"),
// new ButtonBuilder()
// .setCustomId("resumeButton")
// .setStyle(ButtonStyle.Primary)
// .setLabel("Resume"),
// new ButtonBuilder()
// .setCustomId("lyricButton")
// .setStyle(ButtonStyle.Primary)
// .setLabel("Get lyrics")
// );
// queue.metadata.channel.send({ embeds: [embed], components: [row] });
// });
client.DT = new DiscordTogether(client);
client.C = Config;
client.CD = new Collection(); // command cooldown
client.LCD = new Collection(); // level cooldown
client.commands = new Collection();
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
}
client.buttons = new Collection();
const buttonsPath = path.join(__dirname, "buttons");
const buttonFiles = fs
.readdirSync(buttonsPath)
.filter((file) => file.endsWith(".js"));
for (const file of buttonFiles) {
const filePath = path.join(buttonsPath, file);
const button = require(filePath);
client.buttons.set(button.name, button);
}
const contextPath = path.join(__dirname, "contextMenu");
const contextFiles = fs
.readdirSync(contextPath)
.filter((f) => f.endsWith(".js"));
for (const file of contextFiles) {
const filePath = path.join(contextPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
}
const imagesPath = path.join(__dirname, "./images/welcomeImages");
const imagesFiles = fs
.readdirSync(imagesPath)
.filter((f) => f.endsWith(".png"));
client.images = [];
for (const file of imagesFiles) {
client.images.push(path.join(imagesPath, file));
}
const eventPath = path.join(__dirname, "events");
const eventFiles = fs.readdirSync(eventPath).filter((f) => f.endsWith(".js"));
for (const file of eventFiles) {
const filePath = path.join(eventPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, () => {
event.execute(client);
consoleMessage(`Event ${event.name} loaded!`, "index");
});
} else {
client.on(event.name, (...args) => {
event.execute(...args, client);
});
}
}
client.modals = new Collection();
const modalsPath = path.join(__dirname, "modals");
const modalFiles = fs
.readdirSync(modalsPath)
.filter((file) => file.endsWith(".js"));
for (const file of modalFiles) {
const filePath = path.join(modalsPath, file);
const modal = require(filePath);
client.modals.set(modal.name, modal);
}
client.login(client.C.TOKEN);