forked from syntaxbullet/aurorabot
- Create withCommandErrorHandling utility in bot/lib/commandUtils.ts - Migrate economy commands: daily, exam, pay, trivia - Migrate inventory command: use - Migrate admin/moderation commands: warn, case, cases, clearwarning, warnings, note, notes, create_color, listing, webhook, refresh, terminal, featureflags, settings, prune - Add 9 unit tests for the utility - Update AGENTS.md with new recommended error handling pattern
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { createCommand } from "@shared/lib/utils";
|
|
import { AuroraClient } from "@/lib/BotClient";
|
|
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
|
|
import { createSuccessEmbed } from "@lib/embeds";
|
|
import { withCommandErrorHandling } from "@lib/commandUtils";
|
|
|
|
export const refresh = createCommand({
|
|
data: new SlashCommandBuilder()
|
|
.setName("refresh")
|
|
.setDescription("Reloads all commands and config without restarting")
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
execute: async (interaction) => {
|
|
await withCommandErrorHandling(
|
|
interaction,
|
|
async () => {
|
|
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] });
|
|
},
|
|
{ ephemeral: true }
|
|
);
|
|
}
|
|
}); |