const { REST, Routes, WebhookClient } = require('discord.js'); const fs = require('node:fs'); const token = "REDACTED"; const webhookId = "REDACTED"; const webhookToken = "REDACTED"; const clientId = "REDACTED"; const path = require('node:path'); const webhookClient1 = new WebhookClient({ id: webhookId, token: webhookToken }); const axios = require('axios'); const Sentry = require("@sentry/node"); require("./models/JS/Handlers/sentry.js"); const pushoverUserKey = 'redacted'; // Replace with your Pushover User Key const pushoverApiToken = 'redacted'; // Replace with your App API Token function sendPushoverNotification(message, priority) { axios.post('https://api.pushover.net/1/messages.json', { token: pushoverApiToken, user: pushoverUserKey, message: message, title: 'KCH Alert', sound: 'persistent', // Optional: Choose a notification sound priority: priority, // Optional: Set notification priority (1 = high) }) .then(response => { console.log('Notification sent:', response.data); }) .catch(error => { console.error('Failed to send notification:', error.response?.data || error.message); }); } async function deployCommands() { const commands = []; // Grab all the command folders from the commands directory you created earlier const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { // Grab all the command files from the commands directory you created earlier const commandsPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment 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.`); } } } // Construct and prepare an instance of the REST module const rest = new REST().setToken(token); // and deploy your commands! (async () => { try { console.log(`Started refreshing ${commands.length} application (/) commands.`); webhookClient1.send({ content: `Started refreshing ${commands.length} application (/) commands.`, username: 'KCH', avatarURL: 'https://i.imgur.com/AfFp7pu.png', }); // The put method is used to fully refresh all commands in the guild with the current set const data = await rest.put( Routes.applicationCommands(clientId), { body: commands }, ); webhookClient1.send({ content: `Successfully reloaded ${data.length} application (/) commands.`, username: 'KCH', avatarURL: 'https://i.imgur.com/AfFp7pu.png', }); console.log(`Successfully reloaded ${data.length} application (/) commands.`); } catch (error) { // And of course, make sure you catch and log any errors! console.error(error); Sentry.captureException(error); } })(); } module.exports = deployCommands;