Building Ban Checkrrr, a serverless function for checking my Twitch ban list

techygrrrltechygrrrl
4 min read

What is Ban Checkrrr?

Ban Checkrrr is a serverless function built on the Cloudflare Workers infrastructure. It is designed for checking if a user is present on the owner streamer's ban list.

Who is this for?

This is built for streamers who want to programmatically check if a user is on their ban list. The check requires a user ID as people can change their usernames. This can be useful for streamers who are building chat bots or other software, and they don't have token management set up in their current software. This can abstract that complexity and give them an endpoint they can make a request to to get this information.

Why I built this

I am currently building an application in Rust to support Twitch streamers' Discord communities. The purpose of this application is to verify that a user has not been banned prior to being allowed to enter the Discord community.

Ban Checkrrr is a serverless function that will do the check. It acts as a separate micro-service to support the ban checking. It is available right away and can be used by any software or scripts. It was built to support GateKeeprrr.

Motivation behind GateKeeprrr

As a streamer, I would like to ensure that those that join my Discord server have not been banned by me or my mods on Twitch.

This is in an effort to prevent harassment from occurring in Discord while I am streaming.

Possible scenarios this happens:

  • Hate raids that can spread from Twitch to a streamer’s Discord
  • A user has been banned and wants to continue harassing the streamer or their community on Discord

All these disrupt the streamer while they’re streaming.

As a streamer, I would like to generate a unique, one-time use Discord invite link for a user after verifying the users' accounts pass a variety of verification criteria. Included in this verification criteria is the requirement that the user has not been banned on Twitch.

This relates to Discord's Connections feature, which is not currently available.

Choosing TypeScript

I decided to go with TypeScript as the language of choice. While Cloudflare Workers does support Rust, which is the language I am using to build the rest of this solution, I have found from experience that the Cloudflare Workers Rust function is a lot slower than the JavaScript implementation, likely due to the web JavaScript to WASM overhead. Performance is one of the reasons since the main reason people choose Rust over easier languages is the performance, there are no performance gains to choosing Rust for this solution (and actually only performance losses).

I wanted to develop it quickly, and based on my experience using Cloudflare Workers and using the TypeScript template with wrangler, I confidently chose this as the fastest approach to building it.

Infrastructure Decision

I chose to use Cloudflare Workers because they have a generous free tier. The goal was to make something that would be free to host. For that reason, this project is tightly coupled to Cloudflare Workers and uses its key-value storage solution.

💾 Get Ban Checkrrr

You can download the code from Github.

How long does it take to set up?

If you have experience developing applications for Twitch (including experience with creating an application and using the Twitch CLI), and you have experience with the Cloudflare Workers platform (specifically worker functions, using wrangler, and working the KV store and secrets), you can set up Ban Checkrrr in a few minutes.

Ban Checkrrr is tightly coupled to Cloudflare Workers' infrastructure, and implements Twitch's OAuth application API's and uses Twitch's CLI tool, so if you are not familiar with these things, this will take you a bit longer. If you are familiar with reading documentation for software and following instructions to set things up, then this should take you about half an hour to an hour.

📺 Watch the Stream

You can watch the stream on Twitch.

📺 Watch the video collection where I build GateKeeprrr

If you're interested in more content like this, you may want to watch the Twitch collection where I am building out this software. It's mostly built in Rust, but the software described in thsi blog post is built in TypeScript.

At the time of this blog post, GateKeeprrr is still in development, so this collection will grow.

Watch "🔐 Building GateKeeprrr"

📺 Hang out with me and watch me code other things

You can also follow me on Twitch to get alerts for when I stream. I'm techygrrrl on Twitch.

8
Subscribe to my newsletter

Read articles from techygrrrl directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

techygrrrl
techygrrrl

software developer && gamer passionate about software development && games ... catch my twitch streams on twitch where I stream: https://twitch.tv/techygrrrl