Make a local redirect server (e. g. using express)
Validate redirect server by adding http://localhost:<PORT> to https://discord.com/developers/applications/<CLIENT_ID>/oauth2/general
Let a server admin / owner authenticate via https://discord.com/oauth2/authorize?client_id=<CLIENT_ID>&scope=applications.commands.permissions.update&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A<PORT>
Discord changed in an update that bot tokens can't change command permissions so now the following steps are required to automatically set permissions:
http://localhost:<PORT>
tohttps://discord.com/developers/applications/<CLIENT_ID>/oauth2/general
https://discord.com/oauth2/authorize?client_id=<CLIENT_ID>&scope=applications.commands.permissions.update&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A<PORT>
PUT
request to Discord endpoint/applications/<APPLICATION_ID>/guilds/<GUILD_ID>/commands/<COMMAND_ID>/permissions
for each command with payloadpermissions: {id: string, type: 1 | 2 | 3, permission: boolean}[]
(See https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions for more information, specifically https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure for permission array)<APPLICATION_ID>
can be globally received viaDiscordClient._client.application?.id