Kill Me(e6)

Just recently I yeeted my Discord-bot Mee6 from my Server. I explained the reasons often enough: too expensive, not reliable, weird focus on certain (monetizable) functions that I didn’t want to support. That’s why we got rid of it. But what is the alternative?

I don’t want to repeat myself too often here – you know what a bot is, you know what it does. If not, google it – others explained that in every degree of detail you might want already. So we start off with a list: what are important functions to me(e)?

  • Greet new members (Discord itself can do that, but… eh)
  • Reaction roles for verification and ping-roles
  • Special roles for streamers who are live (for as long as they are live)
  • Simple moderation tasks
  • Search functions for anime, manga, Pokémon and the Urban Dictionary
  • Twitch- and YouTube notifications
  • Consolidate the functions we already have in custom bots (stream plan, dadjokes <- essential)
First of all: a plan

These functions did prove themselves worthy to me migrated – others, like the economy system and music features would have been too much trouble to program in regard to how much they are actually used (additionally, YouTube very much dislikes music bots – better not taking the risk).

Obviously my first idea to get rid of Mee was to replace it by another bot out there. Carl-Bot for example provides almost every single of those functions plus more. OG members of my server might remember Carl though – it was the bot prior to Mee and was replaced mostly of the same reasons I replace Mee now. Also I wasn’t sure about trying some random, rarely used bot. Why go through the trouble of migration just to find out it’ll be no longer supported or shut down or whatever; we’d had to start over again.

So my decision was clear: use the two bots I already made as a boilerplate to program a brand new one: consolidating the two existing and extending their functionality with what I want and need. The process of doing so turned out to be divided in three parts; ascending in how difficult and annoying those were:

1. Extend existing functions

To merge the two existing bots was no problem; the division was more of a historical than technical reason. They basically did the following:

  1. Read messages and identify commands
  2. Talk to an external interface (API) and get a result
  3. Send a response to the command

These steps were exactly what I needed for the functions of moderation and searching. Moderation reads messages for certain keywords while search functions watch for commands, extract arguments (what manga are you looking for?) and get a result from an API. The APIs Mee used were documented, which made it even easier.

Mee tells you, where it gets the data from – very handy

The actual implementation was kinda tricky – I had to read and test a lot with those APIs. In the end though, it just worked. Until I got to the next point on my list.

2. Add roles and get your status

The library I use to connect my bot to Discord is called Discord.NET. It makes life easier – mostly. There’s a lot of the same stuff in different varieties and with various options and the error handling is kinda weird, too – most of the times it does not inform you about problems, it just ignores everything and does nothing as a response to a command.

Some of those distinctions might have some reason, but for an average programmer like me it was a lot of struggling and stack-overflowing until I even got an idea of what to do – that took a lot of time. But Discord itself also has some… peculiarities.

A “SocketUser” needs to be casted into a “SocketGuildUser” – of course

What I didn’t know, what I don’t know yet and what I think is utterly stupid is the permission management for bots. An account, which has administrative rights (so it can do anything on your server) cannot see by default which status a user has – even though literally everyone else can. This permission (and some others) are needed to be set through the developer dashboard of Discord – and also be requested by the bot on startup. As I said, I don’t know why and I think it’s stupid. But it is what it is. And since there is no proper error handing, it took a lot of time and a lot of stackoverflow to understand this issue, and to make it work – finally.

List users, get their status and soon also to read messages – what Jack Average can needs to be allowed for a bot with admin rights…
…on both sides

3. YouTube and Twitch

The last hurdle were the notifications. And boy, does this topic suck. Spoiler: I didn’t manage to include this in the bot, it’s again an external service.

Twitch has a very bad documentation for their API. It might be technically and formally correct and complete, but for the average programmer like me, it’s too theoretical – very few and very useless examples only. YouTube is very well documented and has a step-by-step tutorial on the other hand. It just does not work. Nice.

Since I am already constantly fighting with the Twitch-API for my stream bot anyways, I hadn’t have the patience to trial-and-error again. I went the lazy path: using an external service who has to deal with Twitch’s shenanigans themself. IFTTT (if this, then that) is such a service. You define a trigger (e.g. Nino went live) and an action (send message to Discord) and boom – done. Their free tier wasn’t usable for me, since you wait up to an hour (!) for execution after an event triggered, so I bought Pro. It reduces the time to 5 minutes, which is okay, and gives you 20 instead of 5 applets. 5 bucks a month to not deal again with stupid APIs? Count me in.

Pro users wait 5 minutes – free users up to an hour. A different topic for a different rant

So I defined my two triggers (YouTube and Twitch). IFTTT can post directly to Discord, but I’d had to add their bot to my server. Not what I wanted. I wanted it all to be under my brand, under NinoBot.

I won’t go into to much detail with the solution, just that much: as soon as I go live, IFTTT sends a message to one of my servers. That server processes the message and uses something called a “WebHook” to post the live-notification as NinoBot. Boom, done.

As soon as I go live, IFTTT uses a WebHook to communicate with my server – ugly but it works

I guess I could go through the trouble to write that myself, but quite frankly: no. I’m just glad I could outsource this.

Mee is gone

To remove Mee after every function was available in my own bot was a child’s play. I deactivated all plugins and then removed my bot token. I don’t know why, but that made Mee kick my bot entirely from the server – whatever. Reinvited it, and now we’re cooking. The Pokémon-search isn’t working yet, but I’m on it. Their API is another topic for another day. tl;dr: Mee is gone, long live NinoBot!

I hope this quite long and quite technical article was interesting to you. I do my best to make it as in-depth yet as engaging as possible, but I still work on that skill. Let’s hope it only gets better, and don’t hesitate to give feedback!