Update Slash Command w/o Deleting & Recreating #1225
Replies: 1 comment
-
We're in the same boat on this one. I've been doing Discord's docs on this can be found at https://discord.com/developers/docs/tutorials/upgrading-to-application-commands#registering-commands however it should be noted that AbstractRepository's save function automatically calls the PATCH endpoint if the part is already created, so you shouldn't need to delete it. There was a bug I found and patched with #1224 where if saving would return a new part with a new id it wasn't getting cached correctly, so if you were having an issue prior to this PR I would advise updating to the latest dev-main and seeing if the issue is still happening. Please note that Guild commands should be updated almost immediately, but Global commands can take up to an hour to show the changes. The easiest way I've found to do it is to just get the command by name: if (! $commands->get('name', 'ping')) // Create it only if doesn't already exist, or you can ignore this line and just PATCH it anyway.
$commands->save($command); |
Beta Was this translation helpful? Give feedback.
-
Hello,
For the life of me, I couldn't find a command to update an existing slash command.
So I abused $discord->http.
(Wish I could add a way to not send the PATCH request if we don't need to, though.)
Current code is this.
Clarifying: $commandsToRegister is an array of Discord commands, filled with function calls that return the command's details.
Beta Was this translation helpful? Give feedback.
All reactions