-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
126 lines (101 loc) · 3.67 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
const { Discord, Client, Collection } = require("discord.js");
const walkSync = require('./walkSync.js');
const path = require('path')
const client = new Client({
intents: [
"GUILDS",
"GUILD_MEMBERS",
"GUILD_BANS",
"GUILD_INTEGRATIONS",
"GUILD_WEBHOOKS",
"GUILD_INVITES",
"GUILD_VOICE_STATES",
"GUILD_PRESENCES",
"GUILD_MESSAGES",
"GUILD_MESSAGE_REACTIONS",
"GUILD_MESSAGE_TYPING",
"DIRECT_MESSAGES",
"DIRECT_MESSAGE_REACTIONS",
"DIRECT_MESSAGE_TYPING",
],
});
module.exports = client;
// Global Variables
client.slashCommands = new Collection()
client.config = require("./config.json");
client.emotes = require('./config/emotes')
//Admins
client.ADMINS = [
{"lastKnownTag": "confusion#6969", "ID": "790618859173969952"}
]
// Initializing the project
require("./handler")(client);
//MongoDB
const mongo = require('././handler/mongoose')
mongo().then(connection => {
console.log('MongoDB Connection Established!')
})
//Giveaways
const giveawayModel = require('./models/giveaway')
// Init discord giveaways
const { GiveawaysManager } = require('discord-giveaways');
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database. We fetch all documents by passing an empty condition.
return await giveawayModel.find({});
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
// Add the new giveaway to the database
await giveawayModel.create(giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
// Find by messageID and update it
await giveawayModel.findOneAndUpdate({ messageID: messageID }, giveawayData).exec();
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
// Find by messageID and delete it
await giveawayModel.findOneAndDelete({ messageID: messageID }).exec();
// Don't forget to return something!
return true;
}
};
client.giveawaysManager = new GiveawayManagerWithOwnDatabase(client, {
updateCountdownEvery: 30000,
default: {
botsCanWin: false,
embedColor: "RED",
embedColorEnd: '0x2F3136',
reaction: "🎉"
}
});
client.giveawaysManager.on("giveawayReactionAdded", (giveaway, member, reaction) => {
});
client.giveawaysManager.on("giveawayReactionRemoved", (giveaway, member, reaction) => {
});
//Slash command files
client.slashCommandFiles = walkSync(path.join(__dirname, '/SlashCommands'))
//Prerequisites
client.prerequisites = new Collection()
client.prerequisiteFiles = walkSync(path.join(__dirname, '/prerequisites'))
for (const file of client.prerequisiteFiles) {
const prerequisite = require(`${file}`);
client.prerequisites.set(prerequisite.name, prerequisite)
prerequisite.run(client);
}
//Features
client.features = new Collection()
client.featureFiles = walkSync(path.join(__dirname, '/features'))
for (const file of client.featureFiles) {
const feature = require(`${file}`);
client.features.set(feature.name, feature)
feature.run(client);
}
client.login(client.config.token);