Holana/index.js
2022-07-05 23:12:23 +12:00

85 lines
No EOL
2.7 KiB
JavaScript

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