fiffu / arisa3

0 stars 1 forks source link

feat: Optimize to avoid re-registering unchanged commands #111

Open fiffu opened 1 year ago

fiffu commented 1 year ago
  1. Figure out when is the appropriate situation to re-register commands
  2. Figure out how the app should decide on re-registering commands
fiffu commented 1 year ago

From the docs (https://discord.com/developers/docs/interactions/application-commands#registering-a-command):

Global commands have inherent read-repair functionality. That means that if you make an update to a global command, and a user tries to use that command before it has updated for them, Discord will do an internal version check and reject the command, and trigger a reload for that command.

Because commands have unique names within a type and scope, we treat POST requests for new commands as upserts. That means making a new command with an already-used name for your application will update the existing command.

So, redeployment updates commands, which means users' clients temporarily go out-of-sync until the internal reload is triggered either on the background, or through the "read-repair" mechanism.

Since read-repair is disruptive (end-to-end time goes up + user-facing error is flashed), the main benefit of adding app-side logic to avoid making POST calls is to reduce the incidence of read-repair.