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!
Solution:Jump to solution
I would first try doing it through discordjs' client.application.commands but if that doesn't suffice or you want to be lazy then I believe from the top of my head you can also just call .load() on the specific command as opposed to loading all because I'm pretty sure load all does just that but in a for loop.
Other than that though, you are on the right track. Yours is a bit of an edge case honestly.
What you can also consider is not limiting selection to options at all but instead providing an autoconplete. Yes autocomplete can be bypassed but you would handle that by checking if the input is valid and if it's not then asking for valid input through a string select menu. This is what I do @Dragonite as well. You can try /pokemon then type .. idk "pika" and it'll autosuggest Pikachu. But then if you type "/pokemon" and mash your keyboard and hit enter before the autocomplete populates you will get an ephemeral reply with a select menu with suggestions....
2 Replies
Solution
I would first try doing it through discordjs' client.application.commands but if that doesn't suffice or you want to be lazy then I believe from the top of my head you can also just call .load() on the specific command as opposed to loading all because I'm pretty sure load all does just that but in a for loop.
Other than that though, you are on the right track. Yours is a bit of an edge case honestly.
What you can also consider is not limiting selection to options at all but instead providing an autoconplete. Yes autocomplete can be bypassed but you would handle that by checking if the input is valid and if it's not then asking for valid input through a string select menu. This is what I do @Dragonite as well. You can try /pokemon then type .. idk "pika" and it'll autosuggest Pikachu. But then if you type "/pokemon" and mash your keyboard and hit enter before the autocomplete populates you will get an ephemeral reply with a select menu with suggestions.
Since both autocomplete options and the ephemeral reply can be build up dynamically you circumvent the issue entirely.
I'll try out the latter tomorrow, thanks! I haven't toyed with autocomplete yet, so that's an interesting option.
I did try to do the singular load, but it didn't seem to work as intended. In any case, the autocomplete option should fit well, and not have to wait for any changes to propagate at discord's whim.