Updated core files

This commit is contained in:
EmotionChild 2022-12-02 21:53:58 +13:00
parent f0db6ce4c0
commit 099c8edeed
No known key found for this signature in database
GPG key ID: 15EBDFF858B9A65A
3 changed files with 2249 additions and 58 deletions

128
index.js
View file

@ -1,84 +1,100 @@
process.title = 'Giveaway Child'; const fs = require("fs");
const fs = require('fs'); const Discord = require("discord.js");
const Discord = require('discord.js');
const client = new Discord.Client({ const client = new Discord.Client({
intents: [ intents: [
Discord.Intents.FLAGS.GUILDS, Discord.GatewayIntentBits.Guilds,
Discord.Intents.FLAGS.GUILD_MEMBERS, Discord.GatewayIntentBits.GuildMembers,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS Discord.GatewayIntentBits.GuildMessageReactions,
] ],
}); });
const config = require('./config.json'); const config = require("./config.json");
client.config = config; client.config = config;
const synchronizeSlashCommands = require('discord-sync-commands'); const synchronizeSlashCommands = require("discord-sync-commands");
// Init discord giveaways // Init discord giveaways
const { GiveawaysManager } = require('discord-giveaways'); const { GiveawaysManager } = require("discord-giveaways");
client.giveawaysManager = new GiveawaysManager(client, { client.giveawaysManager = new GiveawaysManager(client, {
storage: "./giveaways.json", storage: "./giveaways.json",
default: { default: {
botsCanWin: false, botsCanWin: false,
embedColor: "#FF0000", embedColor: "#FF0000",
reaction: "🎉", reaction: "🎉",
lastChance: { lastChance: {
enabled: true, enabled: true,
content: '⚠️ **LAST CHANCE TO ENTER !** ⚠️', content: "⚠️ **LAST CHANCE TO ENTER !** ⚠️",
threshold: 5000, threshold: 10000,
embedColor: '#FF0000' embedColor: "#FF0000",
} },
} },
}); });
// We now have a client.giveawaysManager property to manage our giveaways! // We not have a client.giveaways property to manage our giveaways
client.giveawaysManager.on("giveawayReactionAdded", (giveaway, member, reaction) => { client.giveawaysManager.on(
console.log(`${member.user.tag} entered giveaway #${giveaway.messageId} (${reaction.emoji.name})`); "giveawayReactionAdded",
}); (giveaway, member, reaction) => {
console.log(
`${member.user.tag} entered giveaway #${giveaway.messageId} (${reaction.emoji.name})`
);
}
);
client.giveawaysManager.on("giveawayReactionRemoved", (giveaway, member, reaction) => { client.giveawaysManager.on(
console.log(`${member.user.tag} unreact to giveaway #${giveaway.messageId} (${reaction.emoji.name})`); "giveawayReactionRemoved",
}); (giveaway, member, reaction) => {
console.log(
`${member.user.tag} unreact to giveaway #${giveaway.messageId} (${reaction.emoji.name})`
);
}
);
client.giveawaysManager.on("giveawayEnded", (giveaway, winners) => { client.giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
console.log(`Giveaway #${giveaway.messageId} ended! Winners: ${winners.map((member) => member.user.username).join(', ')}`); console.log(
`Giveaway #${giveaway.messageId} ended! Winners: ${winners
.map((member) => member.user.username)
.join(", ")}`
);
}); });
/* Load all commands */ /* Load all commands */
client.commands = new Discord.Collection(); client.commands = new Discord.Collection();
fs.readdir("./commands/", (_err, files) => { fs.readdir("./commands/", (_err, files) => {
files.forEach((file) => { files.forEach((file) => {
if (!file.endsWith(".js")) return; if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`); let props = require(`./commands/${file}`);
let commandName = file.split(".")[0]; let commandName = file.split(".")[0];
client.commands.set(commandName, { client.commands.set(commandName, {
name: commandName, name: commandName,
...props ...props,
});
console.log(`👌 Command loaded: ${commandName}`);
});
synchronizeSlashCommands(client, client.commands.map((c) => ({
name: c.name,
description: c.description,
options: c.options,
type: 'CHAT_INPUT'
})), {
debug: true
}); });
console.log(`👌 Command loaded: ${commandName}`);
});
synchronizeSlashCommands(
client,
client.commands.map((c) => ({
name: c.name,
description: c.description,
options: c.options,
type: Discord.ApplicationCommandType.ChatInput,
})),
{
debug: true,
}
);
}); });
/* Load all events */ /* Load all events */
fs.readdir("./events/", (_err, files) => { fs.readdir("./events/", (_err, files) => {
files.forEach((file) => { files.forEach((file) => {
if (!file.endsWith(".js")) return; if (!file.endsWith(".js")) return;
const event = require(`./events/${file}`); const event = require(`./events/${file}`);
let eventName = file.split(".")[0]; let eventName = file.split(".")[0];
console.log(`👌 Event loaded: ${eventName}`); console.log(`👌 Event loaded: ${eventName}`);
client.on(eventName, event.bind(null, client)); client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)]; delete require.cache[require.resolve(`./events/${file}`)];
}); });
}); });
// Login // Login

2175
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -22,9 +22,9 @@
"homepage": "https://github.com/EmotionChild/Giveaway-Child#readme", "homepage": "https://github.com/EmotionChild/Giveaway-Child#readme",
"dependencies": { "dependencies": {
"beautify": "0.0.8", "beautify": "0.0.8",
"discord-giveaways": "^5.0.1", "discord-giveaways": "^6.0.1",
"discord-sync-commands": "0.3.0", "discord-sync-commands": "0.3.0",
"discord.js": "^13.9.0", "discord.js": "^14.6.0",
"fero-ms": "^2.0.7", "fero-ms": "^2.0.7",
"ms": "^2.1.3", "ms": "^2.1.3",
"quickdb": "1.0.5", "quickdb": "1.0.5",