I like to mess around with bots for my social circle’s Discord server, so I’ll catalog them all here.
I have a general purpose bot called Sanctuary Bot that handles a handful of miscellaneous features that compliment the specific way we use our Discord.
- If you paste a link to a tweet that has multiple images, Discord will only embed the first image on its own, so this bot will grab the rest of the images through the Twitter API and upload them as well.
- If you paste a link to a tweet that is quoting another tweet, Discord will just show the outer tweet without context, so this bot will grab the quoted tweet and post it in the channel.
- If you type “!shot twitchChannel” and “twitchChannel” is a user that is currently streaming on Twitch, the bot will load up a single frame of the stream and post it to the channel. (This also has a shortcut called “!owl” for “!shot overwatchleague”)
- If you type “!owlcomp” and there’s currently an Overwatch League match streaming, it will cut out sections from a screenshot of the stream showing the heroes each team has chosen (“comp” as in team composition) and post them to the channel.
As a huge fan of GamesDoneQuick, a speedrunning marathon raising money for charity, I wanted a way to inform a channel on Discord about upcoming runs. This bot (named Velocity after the event’s mascot) scrapes the schedule page and posts into the channel when the next game is within 15 minutes of starting. It also has an on-demand feature to post the current and upcoming games, as well as a reminder feature to be @-mentioned when a game is coming up next.
Webhooks (not actually “bot” scripting, but it’s Discord related so it’s included)
Discord provides the ability to set up webhooks that will auto-post in channels if you send a properly formed payload to a unique URL, so I took advantage of this to grant us the ability to share screenshots from console games directly through the console’s social media sharing features. It involves the following components:
- Twitter account: I made a brand new Twitter account to act as a target and enabled developer tools on it so I can subscribe to events that happen to this account.
- Custom web-accessible script: I host a script on my own server that subscribes to the above-mentioned events, filters to only care about mentions, reads the hashtags, and sends a payload to the appropriate Discord webhook.
- Discord webhooks: I set up a webhook for each game I think my friends are going to want to share screenshots from, as you need to create a webhook for each Discord channel and we organize our channels by game already.
The resulting flow: use the console’s social share feature to post to twitter, make sure you @-mention the Twitter account at the start so Twitter thinks it’s a reply and hides it from followers, insert a corresponding #hashtag to the channel you want to share to, and upload. Twitter events ping the script, the script passes it on to the appropriate webhook, Discord receives it and posts it.