From 34cbea2753d13b7aecd94fc5d1fb995a7d8e18fd Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Thu, 18 Dec 2025 16:37:10 +0100 Subject: [PATCH] remove old reload command --- src/commands/admin/reload.ts | 84 ------------------------------------ 1 file changed, 84 deletions(-) delete mode 100644 src/commands/admin/reload.ts diff --git a/src/commands/admin/reload.ts b/src/commands/admin/reload.ts deleted file mode 100644 index 4b79319..0000000 --- a/src/commands/admin/reload.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { createCommand } from "@lib/utils"; -import { KyokoClient } from "@/lib/BotClient"; -import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, MessageFlags } from "discord.js"; -import { createErrorEmbed, createSuccessEmbed, createWarningEmbed } from "@lib/embeds"; - -export const reload = createCommand({ - data: new SlashCommandBuilder() - .setName("reload") - .setDescription("Reloads all commands") - .addBooleanOption(option => - option - .setName("redeploy") - .setDescription("Pull latest changes from git and restart the bot") - .setRequired(false) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - execute: async (interaction) => { - await interaction.deferReply({ flags: MessageFlags.Ephemeral }); - - const redeploy = interaction.options.getBoolean("redeploy") ?? false; - - if (redeploy) { - const { exec } = await import("child_process"); - const { promisify } = await import("util"); - const { writeFile, utimes } = await import("fs/promises"); - const execAsync = promisify(exec); - - try { - await interaction.editReply({ - embeds: [createWarningEmbed("Pulling latest changes and restarting...", "Redeploy Initiated")] - }); - - // Get current branch - const { stdout: branchName } = await execAsync("git rev-parse --abbrev-ref HEAD"); - const branch = branchName.trim(); - - // Fetch and reset - await execAsync("git fetch --all"); - const { stdout } = await execAsync(`git reset --hard origin/${branch}`); - - await interaction.editReply({ - embeds: [createSuccessEmbed(`Git Reset Output:\n\`\`\`\n${stdout}\n\`\`\`\nRestarting process...`, "Update Successful")] - }); - - // Write context for post-restart notification - await writeFile(".restart_context.json", JSON.stringify({ - channelId: interaction.channelId, - userId: interaction.user.id, - timestamp: Date.now() - })); - - // Trigger restart by touching entry point - const { appendFile } = await import("fs/promises"); - await appendFile("src/index.ts", " "); - - } catch (error) { - console.error(error); - await interaction.editReply({ - embeds: [createErrorEmbed(`Failed to redeploy:\n\`\`\`\n${error instanceof Error ? error.message : String(error)}\n\`\`\``, "Redeploy Failed")] - }); - } - return; - } - - try { - const start = Date.now(); - await KyokoClient.loadCommands(true); - const duration = Date.now() - start; - - // Deploy commands - await KyokoClient.deployCommands(); - - const embed = createSuccessEmbed( - `Successfully reloaded ${KyokoClient.commands.size} commands in ${duration}ms.`, - "System Reloaded" - ); - - await interaction.editReply({ embeds: [embed] }); - } catch (error) { - console.error(error); - await interaction.editReply({ embeds: [createErrorEmbed("An error occurred while reloading commands. Check console for details.", "Reload Failed")] }); - } - } -}); \ No newline at end of file