forked from sandarutharuneth/ivongiveaways
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
101 lines (89 loc) · 3.22 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
const Discord = require("discord.js");
const client = new Discord.Client({ intents: 7753 });
const fs = require("fs");
require("dotenv").config();
// const config = require("./config.json");
const host = require("./host");
// client.config = config;
// Initialise discord giveaways
const { GiveawaysManager } = require("discord-giveaways");
client.giveawaysManager = new GiveawaysManager(client, {
storage: "./storage/giveaways.json",
default: {
botsCanWin: false,
embedColor: "#012D3D",
reaction: "✋",
lastChance: {
enabled: false,
content: `📛 | **Last chance to enter**`,
threshold: 5000,
embedColor: '#012D3D'
}
}
});
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)
});
});
client.on("messageCreate", (message) => {
if (message.author.bot) return false;
if (message.content.includes("@here") || message.content.includes("@everyone") || message.type == "REPLY") return false;
if (message.mentions.has(client.user.id)) {
const botmention = new Discord.MessageEmbed()
.setColor('#012D3D')
.setDescription('▶ **My Prefix:** `-` \n▶ **You can see my all commands type:** `-help`\n▶ **All the giveawy commands are availble on Slash**')
message.reply({embeds: [botmention]});
}
});
// Login through the client
// client.login(config.token);
// Use this if you're using Replit and delete the line above.
client.login(process.env.TOKEN);