feat: split reload command into refresh for command reloading and update for git-based bot restarts with update checking and confirmation.

This commit is contained in:
syntaxbullet
2025-12-18 16:36:23 +01:00
parent 4ac8b4759e
commit ce7d4525b2
3 changed files with 156 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
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 refresh = createCommand({
data: new SlashCommandBuilder()
.setName("refresh")
.setDescription("Reloads all commands and config without restarting")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
execute: async (interaction) => {
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
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 Refreshed"
);
await interaction.editReply({ embeds: [embed] });
} catch (error) {
console.error(error);
await interaction.editReply({ embeds: [createErrorEmbed("An error occurred while refreshing commands. Check console for details.", "Refresh Failed")] });
}
}
});