forked from syntaxbullet/AuroraBot-discord
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { createCommand } from "@shared/lib/utils";
|
|
import { AuroraClient } from "@/lib/BotClient";
|
|
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from "discord.js";
|
|
import { createErrorEmbed, createSuccessEmbed } 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 AuroraClient.loadCommands(true);
|
|
const duration = Date.now() - start;
|
|
|
|
// Deploy commands
|
|
await AuroraClient.deployCommands();
|
|
|
|
const embed = createSuccessEmbed(
|
|
`Successfully reloaded ${AuroraClient.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")] });
|
|
}
|
|
}
|
|
}); |