-
Notifications
You must be signed in to change notification settings - Fork 131
/
index.js
103 lines (92 loc) · 3.18 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
const Discord = require("discord.js")
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const client = new Client({
partials: [
Partials.Message, // for message
Partials.Channel, // for text channel
Partials.GuildMember, // for guild member
Partials.Reaction, // for message reaction
],
intents: [
GatewayIntentBits.Guilds, // for guild related things
GatewayIntentBits.GuildInvites, // for guild invite managing
GatewayIntentBits.GuildMessages, // for guild messages things
GatewayIntentBits.GuildMessageReactions, // for message reactions things
GatewayIntentBits.MessageContent, // enable if you need message content things
],
});
const fs = require("fs");
const config = require("./config.json");
client.config = config;
// Initialise discord giveaways
const { GiveawaysManager } = require("discord-giveaways");
client.giveawaysManager = new GiveawaysManager(client, {
storage: "./storage/giveaways.json",
default: {
botsCanWin: false,
embedColor: "#2F3136",
reaction: "🎉",
lastChance: {
enabled: true,
content: `🛑 **Last chance to enter** 🛑`,
threshold: 5000,
embedColor: '#FF0000'
}
}
});
//Coded by ZeroSync on yt
/* Load all events (discord based) */
fs.readdir("./events/discord", (_err, files) => {
files.forEach(file => {
if (!file.endsWith(".js")) return;
const event = require(`./events/discord/${file}`);
let eventName = file.split(".")[0];
console.log(`[Event] ✅ Loaded: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/discord/${file}`)];
});
});
/* Load all events (giveaways based) */
fs.readdir("./events/giveaways", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/giveaways/${file}`);
let eventName = file.split(".")[0];
console.log(`[Event] 🎉 Loaded: ${eventName}`);
client.giveawaysManager.on(eventName, (...file) => event.execute(...file, client)), delete require.cache[require.resolve(`./events/giveaways/${file}`)];
})
})
// Let commands be a new collection ( message commands )
client.commands = new Discord.Collection();
/* Load all commands */
fs.readdir("./commands/", (_err, files) => {
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, {
name: commandName,
...props
});
console.log(`[Command] ✅ Loaded: ${commandName}`);
});
});
// let interactions be a new collection ( slash commands )
client.interactions = new Discord.Collection();
// creating an empty array for registering slash commands
client.register_arr = []
/* Load all slash commands */
fs.readdir("./slash/", (_err, files) => {
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(`./slash/${file}`);
let commandName = file.split(".")[0];
client.interactions.set(commandName, {
name: commandName,
...props
});
client.register_arr.push(props)
});
});
// Login through the client
client.login(config.token);