2023-11-16 23:32:16 +00:00
|
|
|
// Require the necessary discord.js classes
|
2023-11-26 23:02:34 +00:00
|
|
|
const fs = require('node:fs');
|
|
|
|
const path = require('node:path');
|
|
|
|
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
|
2023-11-19 23:59:41 +00:00
|
|
|
|
2023-11-26 23:02:34 +00:00
|
|
|
const { config } = require('dotenv');
|
2023-11-19 23:59:41 +00:00
|
|
|
config();
|
2023-11-16 23:32:16 +00:00
|
|
|
|
2023-11-26 23:02:34 +00:00
|
|
|
const { igdb } = require('./igdb.js');
|
2023-12-30 22:45:52 +00:00
|
|
|
const { backupDatabase } = require('./databaseHelperFunctions.js');
|
2023-11-27 23:40:14 +00:00
|
|
|
new igdb();
|
2023-11-20 22:07:05 +00:00
|
|
|
|
2023-11-16 23:32:16 +00:00
|
|
|
// Create a new client instance
|
|
|
|
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
|
|
|
|
2023-11-17 23:23:51 +00:00
|
|
|
client.commands = new Collection();
|
2023-11-18 20:27:42 +00:00
|
|
|
client.cooldowns = new Collection();
|
2023-11-17 23:23:51 +00:00
|
|
|
|
|
|
|
const foldersPath = path.join(__dirname, 'commands');
|
|
|
|
const commandFolders = fs.readdirSync(foldersPath);
|
|
|
|
|
|
|
|
for (const folder of commandFolders) {
|
|
|
|
const commandsPath = path.join(foldersPath, folder);
|
|
|
|
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
|
|
|
const filePath = path.join(commandsPath, file);
|
2023-11-26 23:02:34 +00:00
|
|
|
const command = require(filePath);
|
2023-11-17 23:23:51 +00:00
|
|
|
|
|
|
|
// Set a new item in the collection with the key as the command name and the value as the exported module
|
|
|
|
if ('data' in command && 'execute' in command) {
|
|
|
|
client.commands.set(command.data.name, command);
|
|
|
|
} else {
|
2023-11-17 23:28:36 +00:00
|
|
|
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
|
2023-11-17 23:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-17 23:48:17 +00:00
|
|
|
const eventsPath = path.join(__dirname, 'events');
|
|
|
|
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
|
2023-11-17 23:23:51 +00:00
|
|
|
|
2023-11-17 23:48:17 +00:00
|
|
|
for (const file of eventFiles) {
|
|
|
|
const filePath = path.join(eventsPath, file);
|
2023-11-26 23:02:34 +00:00
|
|
|
const event = require(filePath);
|
2023-11-17 23:48:17 +00:00
|
|
|
if (event.once) {
|
|
|
|
client.once(event.name, (...args) => event.execute(...args));
|
|
|
|
} else {
|
|
|
|
client.on(event.name, (...args) => event.execute(...args));
|
2023-11-17 23:23:51 +00:00
|
|
|
}
|
2023-11-17 23:48:17 +00:00
|
|
|
}
|
2023-11-16 23:32:16 +00:00
|
|
|
|
2023-12-30 00:50:23 +00:00
|
|
|
client.login(process.env.discordToken);
|
2023-11-26 23:02:34 +00:00
|
|
|
|
|
|
|
client.once(Events.ClientReady, () => {
|
|
|
|
console.log(`Logged in as ${client.user.tag}!`);
|
2023-12-18 21:55:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
require('sequelize');
|
2023-12-30 22:45:52 +00:00
|
|
|
require('./dbObjects.js');
|
|
|
|
|
|
|
|
if (!fs.existsSync('./backups')) {
|
|
|
|
fs.mkdir('./backups', (err) => {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
backupDatabase();
|
|
|
|
}, 86000000);
|
|
|
|
|
|
|
|
backupDatabase();
|