Holana/index.js

103 lines
2.6 KiB
JavaScript
Raw Normal View History

2023-03-28 09:07:56 +00:00
process.title = 'Giveaway Child';
2022-12-02 08:53:58 +00:00
const fs = require("fs");
2022-05-23 07:40:08 +00:00
2022-12-02 08:53:58 +00:00
const Discord = require("discord.js");
2021-10-08 23:58:57 +00:00
const client = new Discord.Client({
2023-03-28 09:07:56 +00:00
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
2021-10-08 23:58:57 +00:00
});
2022-12-02 08:53:58 +00:00
const config = require("./config.json");
2021-10-08 23:58:57 +00:00
client.config = config;
2022-12-02 08:53:58 +00:00
const synchronizeSlashCommands = require("discord-sync-commands");
2021-10-08 23:58:57 +00:00
// Init discord giveaways
2022-12-02 08:53:58 +00:00
const { GiveawaysManager } = require("discord-giveaways");
2021-10-08 23:58:57 +00:00
client.giveawaysManager = new GiveawaysManager(client, {
2022-12-02 08:53:58 +00:00
storage: "./giveaways.json",
default: {
botsCanWin: false,
embedColor: "#FF0000",
reaction: "🎉",
lastChance: {
enabled: true,
content: "⚠️ **LAST CHANCE TO ENTER !** ⚠️",
2023-03-28 09:07:56 +00:00
threshold: 5000,
2022-12-02 08:53:58 +00:00
embedColor: "#FF0000",
},
},
2021-10-08 23:58:57 +00:00
});
2023-03-28 09:07:56 +00:00
// We now have a client.giveawaysManager property to manage our giveaways!
2021-10-08 23:58:57 +00:00
2022-12-02 08:53:58 +00:00
client.giveawaysManager.on(
"giveawayReactionAdded",
(giveaway, member, reaction) => {
console.log(
`${member.user.tag} entered giveaway #${giveaway.messageId} (${reaction.emoji.name})`
);
}
);
2021-10-08 23:58:57 +00:00
2022-12-02 08:53:58 +00:00
client.giveawaysManager.on(
"giveawayReactionRemoved",
(giveaway, member, reaction) => {
console.log(
`${member.user.tag} unreact to giveaway #${giveaway.messageId} (${reaction.emoji.name})`
);
}
);
2021-10-08 23:58:57 +00:00
client.giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
2022-12-02 08:53:58 +00:00
console.log(
`Giveaway #${giveaway.messageId} ended! Winners: ${winners
.map((member) => member.user.username)
.join(", ")}`
);
2021-10-08 23:58:57 +00:00
});
/* Load all commands */
client.commands = new Discord.Collection();
fs.readdir("./commands/", (_err, files) => {
2022-12-02 08:53:58 +00:00
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,
2021-10-08 23:58:57 +00:00
});
2022-12-02 08:53:58 +00:00
console.log(`👌 Command loaded: ${commandName}`);
});
synchronizeSlashCommands(
client,
client.commands.map((c) => ({
name: c.name,
description: c.description,
options: c.options,
2023-03-28 09:07:56 +00:00
type: "CHAT_INPUT",
2022-12-02 08:53:58 +00:00
})),
{
debug: true,
}
);
2021-10-08 23:58:57 +00:00
});
/* Load all events */
fs.readdir("./events/", (_err, files) => {
2022-12-02 08:53:58 +00:00
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}`)];
});
2021-10-08 23:58:57 +00:00
});
// Login
client.login(config.token);