speedruncomorg / api

REST API Documentation for speedrun.com
346 stars 36 forks source link

Feature Request: Add support for webhooks, particularly for Discord #148

Open dshepsis opened 2 years ago

dshepsis commented 2 years ago

Webhooks would allow external services to receive messages about events on speedruncom. For example, a website could receive a callback whenever a new run is submitted, or whenever the rules are changed for a particular game and category. This avoids the need to make periodic requests to the API to check if changes have occurred.

Relatedly, Discord offers support for Webhooks, which is documented here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks and here: https://discord.com/developers/docs/resources/webhook.

If webhooks formatted for Discord were supported, a speedrunning-community Discord server could easily create a channel to which messages are sent whenever specified events occur on their speedruncom leaderboard. This wouldn't require any coding or creating/operating a bot. I think it could also reduce load on speedruncom's servers, since bots wouldn't need to make periodic requests for such updates.

For implementation, I imagine webhooks would be implemented both for games and for users. For game webhooks, they would be enabled and configured in the /editgame page, as an extra tab. Game moderators would be able to create multiple webhooks for the same game. For each webhook, they would provide a URL (such as those generated by Discord when creating a webhook in a guild text channel) to which speedruncom would send messages. They would then have a list of checkboxes corresponding to which messages they would like to receive at that URL. For example, there would be options for:

Each type of message could itself have some configuration, such as customizing the message sent.

User webhooks would be similar, except specific to a user. This would be useful if a user wanted to have updates posted to their personal Discord server. They would be configured in the user /settings page.