Seraphim
Seraphim
SIASapphire - Imagine a framework
Created by Seraphim on 1/14/2025 in #sapphire-support
Re-registering Command Within Scope of chatInputRun
Hey all, In short, I've been looking for a way to re-register a command definition in a subcommand that allows an admin of a server to create a currency type (XP, SapphirePoints, etc., it's arbitrary). These currency types needs to show up in other subcommands for admin, therefore re-registering seems necessary to alter the choices presented for such fields. The only thing that works without restarting the client seems to be a call to this.store.loadAll(). Just checking if this is a foolish way to achieve this goal, or if there's something better. I had initially figured just calling registry.registerChatInputCommand() might do the trick, but that does not seem to be the case. I also tried to just load this specific command, though that did not do the job. I appreciate it!
async createCurrencyAsync(interaction: Command.ChatInputCommandInteraction, requestorGuild: Guild): Promise<any> {
requestorGuild.createCurrencyType(interaction.options.getString('name', true))

await this.guildRepository.saveAsync(interaction.user.id)
await this.registerGuildSpecificCurrencyOptions(this.applicationCommandRegistry, requestorGuild)


...logging and replies omitted from example. loadAll can take a little bit, so is called last.

await this.store.loadAll()
}
async createCurrencyAsync(interaction: Command.ChatInputCommandInteraction, requestorGuild: Guild): Promise<any> {
requestorGuild.createCurrencyType(interaction.options.getString('name', true))

await this.guildRepository.saveAsync(interaction.user.id)
await this.registerGuildSpecificCurrencyOptions(this.applicationCommandRegistry, requestorGuild)


...logging and replies omitted from example. loadAll can take a little bit, so is called last.

await this.store.loadAll()
}
6 replies