discord: add initial slash command integration.

Add initial support for the `/count <tags>` and `/posts <tags>` slash commands.

Slash commands are basically like webhooks; we register a command, and
when anybody types that command in Discord, Discord sends us a HTTP
request that we respond to.

* https://discord.com/developers/docs/interactions/slash-commands
* https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ
This commit is contained in:
evazion
2021-03-11 02:55:50 -06:00
parent 1c2f3abe56
commit 2c8c7ff80a
8 changed files with 321 additions and 1 deletions

View File

@@ -402,6 +402,29 @@ module Danbooru
def discord_webhook_secret
end
# Settings used for Discord slash commands.
#
# * Go to https://discord.com/developers/applications
# * Create an application.
# * Copy the client ID and public key.
# * Create a bot user.
# * Copy the bot token.
# * Go to the OAuth2 page, select the `bot` and `applications.commands`
# scopes, and the `Administrator` permission, then follow the oauth2
# link to add the bot to the Discord server.
def discord_application_client_id
end
def discord_application_public_key
end
def discord_bot_token
end
# The ID of the Discord server to register slash commands for.
def discord_guild_id
end
# you should override this
def email_key
"zDMSATq0W3hmA5p3rKTgD"