This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths-index.js
371 lines (319 loc) · 13.4 KB
/
s-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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
// _____ _ _
// / ____| | | |
// | (___ | | __ _ ___| |__ _ __
// \___ \| |/ _` / __| '_ \| '__|
// ____) | | (_| \__ \ | | | |
// |_____/|_|\__,_|___/_| |_|_|
// __ __ _ _ _______ _ _
// | \/ | | | | | |__ __| | | | |
// | \ / | __ _ __| | ___ | |__ _ _ | |_ _ _ __| |_| | ___ _ __ __ ___ __
// | |\/| |/ _` |/ _` |/ _ \ | '_ \| | | | | | | | | '__| __| |/ _ \ '_ \ / _` \ \ /\ / /
// | | | | (_| | (_| | __/ | |_) | |_| | | | |_| | | | |_| | __/ |_) | (_| |\ V V /
// |_| |_|\__,_|\__,_|\___| |_.__/ \__, | |_|\__,_|_| \__|_|\___| .__/ \__,_| \_/\_/
// __/ | | |
// |___/ |_|
const Discord = require('discord.js');
const { ContextMenuBuilder } = require("discord.js-util");
const config = require('./config.json');
const fs = require('fs');
const klawSync = require('klaw-sync')
const mongoose = require('mongoose');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildId, token } = require('./config.json');
const COMMAND_MANAGER = require('./models/slash-command.manager');
const SERVER_MANAGER = require('./models/server.manager');
const emojis = require('./emojis.json');
mongoose.connect(config.mongoose, { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.connection.on('connecting', () => {
console.log("Mongoose: Logging in!")
})
mongoose.connection.on('connected', () => {
console.log("Mongoose: Logged in!")
})
mongoose.connection.on('disconnecting', () => {
console.log("Mongoose: Logging out")
})
mongoose.connection.on('disconnected', () => {
console.log("Mongoose: Logged out")
})
mongoose.connection.on('error', error => {
console.log(error)
})
const client = new Discord.Client({
intents: ["GUILDS", "GUILD_MEMBERS", "GUILD_PRESENCES", "GUILD_INTEGRATIONS", "GUILD_VOICE_STATES", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", "DIRECT_MESSAGES", "DIRECT_MESSAGE_REACTIONS"],
});
const client2 = new Discord.Client({
intents: ["GUILDS", "GUILD_MEMBERS", "GUILD_PRESENCES", "GUILD_INTEGRATIONS", "GUILD_VOICE_STATES", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", "DIRECT_MESSAGES", "DIRECT_MESSAGE_REACTIONS"],
});
//...
let ready = false
module.exports.ready = false
client.once('ready', async () => {
console.log('Ready! %s', client.user.tag);
//Set presence
client.user.setPresence({ activities: [{ name: `Creating slash commands in ${client.guilds.cache.size} guild` }], status: 'online' });
setTimeout(() => {
setInterval(() => {
client.user.setPresence({ activities: [{ name: `Creating slash commands in ${client.guilds.cache.size} guild` }], status: 'online' });
}, 60000);
const emojis = new EmojiManager(client);
client.botEmojis = emojis.emojis
ready = true
module.exports.ready = true
console.log("Emojis Ready!")
}, 4000);
});
client.check = "<:checkmark_d:925583512118120507>"
client.x = "<:xmark_d:925583718402359346>"
client.dashboardAdd = `https://discord.gg/PWXGdJFdPH`
//Client 2 Start
client2.once('ready', async () => {
console.log('Ready! %s', client2.user.tag);
//Set presence
client2.user.setPresence({ activities: [{ name: `to Slash Commands` }], status: 'listening' });
})
const sCommands = [
new SlashCommandBuilder().setName('command').setDescription('Search a command').addStringOption(o => {
return o.setName('command')
.setRequired(false)
.setDescription('The command to search for.')
})
].map(command => command.toJSON());
const rest2 = new REST({ version: '9' }).setToken(require('./config.json').token2);
(async () => {
try {
await rest2.put(
Routes.applicationCommands('886391965661397032'),
{ body: sCommands },
);
console.log('Successfully registered application (/) commands.');
} catch (error) {
console.error(error);
}
})();
client2.on('interactionCreate', async i => {
if (!i.isCommand()) return
if (i.commandName === 'command') {
if (i.options.getString('command')) {
const COMMAND_NAME = i.options.getString('command').replace(/ /g, "-");
const COMMAND = await COMMAND_MANAGER.getCommand(COMMAND_NAME, i.guildId)
COMMAND_MANAGER.useCommand(COMMAND_NAME, i.guildId)
const TEXT = COMMAND?.reply
if (COMMAND?.embed === true) {
const replyembed = new Discord.MessageEmbed()
.setTitle(require('discord-turtle').util.fixCase(COMMAND.name))
.setDescription(TEXT)
if ((await SERVER_MANAGER.hasColor(i.guild.id))) {
replyembed.setColor((await SERVER_MANAGER.findOne(interaction.guild.id).options?.color))
}
await i.reply({ embeds: [replyembed] })
} else {
await i.reply({ content: TEXT.toString() })
}
} else {
const ALL_COMMANDS = await COMMAND_MANAGER.getAll(i.guildId);
const EMBED = new Discord.MessageEmbed()
.setColor(require('./color.json').color)
for (const Commandd of ALL_COMMANDS) {
EMBED.addField(`${emojis.slashCommand} \`${Commandd.name}\``, `${emojis.user_add} \`${Commandd.uses || "0"} uses\``, true)
}
i.reply({ embeds: [EMBED], ephemeral: true })
}
}
})
client2.login(require('./config.json').token2)
//Client 2 End
module.exports.client = client;
module.exports.getClient = () => client;
client.commands = new Discord.Collection();
client.slashcmds = new Discord.Collection();
client.config = config;
//...
const slashFiles = klawSync('./commands', { nodir: true, traverseAll: true, filter: f => f.path.endsWith('.js') });
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
// const clientFiles = fs.readdirSync('./client').filter(file => file.endsWith('.js'));
// for (const file of clientFiles) {
// const filee = require(`./client/${file}`);
// filee.execute(client)
// }
const slshcmdArray = []
// Here we load all the commands into client.commands
for (const file of slashFiles) {
const command = require(`${file.path}`);
console.log(`loading slash/${file.path}`);
// set a new item in the Collection
// with the key as the command name and the value as the exported module
client.slashcmds.set(command.name, command);
slshcmdArray.push(command)
}
//From https://discordjs.guide/creating-your-bot/creating-commands.html#command-deployment-script
const slshCommands = []
const slashCommands = []
for (const cmd of slshcmdArray) {
if (cmd.data) {
if (cmd.devOnly === true) {
slashCommands.push(cmd.data)
} else {
slshCommands.push(cmd.data)
}
}
}
slshCommands.map(command => command.toJSON());
const menus = {
beta: [
],
pub: [
new ContextMenuBuilder()
.setName(`Show All Roles`)
.setType("MESSAGE"),
new ContextMenuBuilder()
.setName(`Show All Roles`)
.setType("USER"),
]
}
if (menus.beta.length > 0) {
for (const menu of menus.beta) {
slashCommands.push(menu.toJSON())
}
}
for (const menu of menus.pub) {
slshCommands.push(menu.toJSON())
}
const rest = new REST({ version: '9' }).setToken(token);
(async () => {
try {
await require('./top.gg')(client);
await rest.put(
Routes.applicationCommands(clientId),
{ body: slshCommands },
);
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: slashCommands }
);
console.log('Successfully registered application commands.');
} catch (error) {
console.error(error);
}
})();
//End
const errorr = new Discord.MessageEmbed()
.setTitle(`That's a 404`)
.setColor(`YELLOW`)
.setDescription(`This is a problem at our end we are clearing it up, please try again in a bit if it still does not work use ,problem`)
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
console.log(`received interaction ${interaction.commandName} by ${interaction.user.tag}`);
const commandName = interaction.commandName;
const command = client.slashcmds.get(commandName);
if (!command) {
//...
}
else {
try {
await command.execute(client, interaction);
} catch (error) {
console.error(error);
}
}
});
var commandFiles = klawSync('./d-commands', { nodir: true, traverseAll: true, filter: f => f.path.endsWith('.js') })
for (const file of commandFiles) {
const command = require(`${file.path}`);
console.log(`loading ${command.name}: ${file.path}`);
// set a new item in the Collection
// with the key as the command name and the value as the exported module
client.commands.set(command.name, command);
}
client.on('messageCreate', async message => {
var Member;
var differentDays = 0;
if (message.mentions.members) {
Member = message.mentions.members.first()
if (!Member) {
Member = message.member
}
}
if (Member) {
var joinedSince = new Date() - Member.joinedAt
differentDays = Math.round(joinedSince / (1000 * 3600 * 24));
}
message.differentDays = differentDays;
message.client = client;
if (message.author.bot) {
return
}
if (message.content.startsWith(config.prefix) && !message.author.bot) {
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) {
//message.reply(`That's not a command ${cat}`);
}
else {
try {
command.execute(message, Member, args);
} catch (error) {
console.error("Yikes!!");
console.error(error);
}
}
}
});
const prime = require('./models/premium');
const EmojiManager = require('./emojis.api');
setInterval(async () => {
const conditional = {
expd: false
}
const results = await prime.find(conditional)
if (results && results.length) {
for (const result of results) {
if (Number(result.exp) === 0) return
if (Number(result.redeemedAt) >= Number(result.exp)) {
const guildPremium = client.guilds.cache.get(result.guild);
if (guildPremium) {
require('./log').log(`${guildPremium.name}'s premium ran out!`, 'premium')
const timeemoj = client.emojis.cache.get('846868929065517066');
const infoemoj = client.emojis.cache.get('860201073305583637');
const embed = new Discord.MessageEmbed()
.setColor(require('./color.json').color)//guildPremium.name
.setDescription(`${infoemoj} Hey,\n\n${timeemoj} ${guildPremium.name}'s premium just expired... <a:blobsigh:855262242215690251>`)
.setFooter('Slash commands premium')
.addField(`${require('../color.json').links_blank}`, `${require('../color.json').links}`)
guildPremium.channels.cache.first().send({ embeds: [embed] }).then(m => {
require('./log').log(`${guildPremium.name}'s premium ran out!`, 'premium', m)
});
await prime.findOneAndDelete({
id: result.id
});
}
}
}
}
}, 1000)
client.login(config.token);
// _____ _ _
// / ____| | | |
// | (___ | | __ _ ___| |__ _ __
// \___ \| |/ _` / __| '_ \| '__|
// ____) | | (_| \__ \ | | | |
// |_____/|_|\__,_|___/_| |_|_|
// __ __ _ _ _______ _ _
// | \/ | | | | | |__ __| | | | |
// | \ / | __ _ __| | ___ | |__ _ _ | |_ _ _ __| |_| | ___ _ __ __ ___ __
// | |\/| |/ _` |/ _` |/ _ \ | '_ \| | | | | | | | | '__| __| |/ _ \ '_ \ / _` \ \ /\ / /
// | | | | (_| | (_| | __/ | |_) | |_| | | | |_| | | | |_| | __/ |_) | (_| |\ V V /
// |_| |_|\__,_|\__,_|\___| |_.__/ \__, | |_|\__,_|_| \__|_|\___| .__/ \__,_| \_/\_/
// __/ | | |
// |___/ |_|