added status command

This commit is contained in:
valentijn
2024-01-04 16:18:10 +01:00
parent 5fa398bffe
commit 78a9688276
6 changed files with 441 additions and 0 deletions

44
updateCommands.js Normal file
View File

@@ -0,0 +1,44 @@
const { REST, Routes } = require('discord.js');
const { clientId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const updateCommands = () => {
const commands = [];
const foldersPath = path.join(__dirname, 'commands');
for (const folder of fs.readdirSync(foldersPath)) {
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);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
const rest = new REST().setToken(token);
(async () => {
try {
console.log(`⚙️ Started refreshing ${commands.length} application (/) commands.`);
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log(`✅ Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(`${error}`);
}
})();
}
module.exports = {
updateCommands
}