Holana/index.js

103 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2023-11-26 01:26:08 -08:00
process.title = 'Holana';
const fs = require("fs");
2022-07-05 04:12:23 -07:00
2023-04-29 02:59:08 -07:00
const Discord = require("discord.js");
2023-11-26 01:26:08 -08:00
const client = new Discord.Client({
2023-04-29 02:59:08 -07:00
intents: [
2023-11-26 01:26:08 -08:00
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildMessageReactions,
2023-04-29 02:59:08 -07:00
],
2021-10-08 16:58:57 -07:00
});
2023-11-26 01:26:08 -08:00
const config = require("./config.json");
2021-10-08 16:58:57 -07:00
client.config = config;
2023-11-26 01:26:08 -08:00
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: 10000,
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(", ")}`
2023-04-29 02:59:08 -07:00
);
2021-10-08 16:58:57 -07:00
});
2023-11-26 01:26:08 -08:00
/* Load all commands */
client.commands = new Discord.Collection();
fs.readdir("./commands/", (_err, files) => {
2023-04-29 02:59:08 -07:00
files.forEach((file) => {
if (!file.endsWith(".js")) return;
2023-11-26 01:26:08 -08:00
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, {
name: commandName,
...props,
});
console.log(`👌 Command loaded: ${commandName}`);
2023-04-29 02:59:08 -07:00
});
2023-11-26 01:26:08 -08:00
synchronizeSlashCommands(
client,
client.commands.map((c) => ({
name: c.name,
description: c.description,
options: c.options,
type: Discord.ApplicationCommandType.ChatInput,
})),
{
debug: true,
}
);
2021-10-08 16:58:57 -07:00
});
2023-11-26 01:26:08 -08:00
/* Load all events */
fs.readdir("./events/", (_err, files) => {
2023-04-29 02:59:08 -07:00
files.forEach((file) => {
if (!file.endsWith(".js")) return;
2023-11-26 01:26:08 -08:00
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}`)];
2023-04-29 02:59:08 -07:00
});
2021-10-08 16:58:57 -07:00
});
2023-11-26 01:26:08 -08:00
// Login
2021-10-08 16:58:57 -07:00
client.login(config.token);