-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
66 lines (57 loc) · 2.58 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
const { Client, Collection, Events, GatewayIntentBits, Partials } = require("discord.js");
const client = new Client({
intents: [GatewayIntentBits.AutoModerationConfiguration, GatewayIntentBits.AutoModerationExecution, GatewayIntentBits.DirectMessageReactions, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent],
partials: [Partials.Message, Partials.Channel, Partials.GuildMember, Partials.Reaction, Partials.GuildScheduledEvent, Partials.User, Partials.ThreadMember],
shards: "auto"
});
const config = require("./src/config.js");
const { readdirSync } = require("node:fs");
const moment = require("moment");
let token = config.token;
client.commandaliases = new Collection();
client.commands = new Collection();
client.slashcommands = new Collection();
client.slashdatas = [];
function log(message) {
console.log(`[${moment().format("DD-MM-YYYY HH:mm:ss")}] ${message}`);
};
client.log = log
// Command handler
readdirSync("./src/commands/prefix").forEach(async (file) => {
const command = await require(`./src/commands/prefix/${file}`);
if (command) {
client.commands.set(command.name, command);
if (command.aliases && Array.isArray(command.aliases)) {
command.aliases.forEach((alias) => {
client.commandaliases.set(alias, command.name);
});
}
}
});
// Slash command handler
const slashcommands = [];
readdirSync("./src/commands/slash").forEach(async (file) => {
const command = await require(`./src/commands/slash/${file}`);
client.slashdatas.push(command.data.toJSON());
client.slashcommands.set(command.data.name, command);
});
// Event handler
readdirSync("./src/events").forEach(async (file) => {
const event = await require(`./src/events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
});
// Process listeners
process.on("unhandledRejection", (e) => {
console.log(e);
});
process.on("uncaughtException", (e) => {
console.log(e);
});
process.on("uncaughtExceptionMonitor", (e) => {
console.log(e);
});
client.login(token);