Programming a Pi With a Discord Bot Part 1 (of 1 hopefully)

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I’m inching back into actual programming with the skills I’ve built up with SSH over the past month paving the way with a bit smoother workflow. Let’s get started!

A few weeks back, I was made an admin on a Discord server after an unsavory character I shall only refer to as Z nuked it majorly. He took advantage of the owner’s weakened state after constant raids, unbanned pretty much everyone, and kicked about two thirds of the total population. Z’s rampage went on for around 10 minutes, but he caused massive damage.

As an admin, I’m helping rebuild the server. One of the tasks is rebanning everyone Z unbanned. Oops. Discord only gives you the option to ban someone if they have some sort of presence on the server by way of being a member or having a message.

When Discord bans someone, it offers to permanently delete a few days of messages from them. Troll tactics often involve getting a bunch of alt accounts on at a time for wide-spread harassment. When the server staff is doing a good job, alt accounts get banned quickly, and all traces of them are incidentally removed from the server. Bad news for me when trying to reban.

The good news is that Discord have a little more access to Discord’s full feature set, and one of those tools is banning accounts without needing a membership or a post. However, with a new goal in a slightly unfamiliar field, that implies new learning to be had.

The first step was defining what exactly I want it to do: Reban the unreachable. Next, I settled on hard coding each name that still needed banning. I’ve had issues with bot stability when running someone else’s dice bot myself, but I don’t need to worry since the finished bot need only run once and it’s done, ready to archive.

The hardest part would have been getting Python3 on. Lucky me, I have the earliest version of Python supported by Discord’s Python wrapper already installed on Blinkie from my naughty kitty project. I just had to install a few dependencies.

I met someone on Discord by the handle of Damaged who I got the majority of my assistance from. They actually pointed me in the direction of programming my own bot instead of just trusting someone else’s. “What I can say is that you need to be very careful of any bot you want to get to [ban people]. You’re effectively going to give them the keys to the castle.” Security is of concern. I once hacked a new bot (with permission from an admin) into pinging everyone when a normal account doesn’t let you do that. The last thing I want to do is let possible trolls have devastating tools I left laying around.

Banning doesn’t sound like anything too fancy to program, and the skills and tools I develop for this project should be useful later. I learned how Discord bots log into bot accounts with some kind of token. I learned how to tell the bot to print its account ID to the command line and use that to add its account to a server. As of the writing of this post, I have gotten a sample bot debugged and running and responding to a simple command.

The next step was a little revision in plans. I have about 50 names to reban or so in total, and bots can theoretically easily do the deed quickly and more thoroughly than I can. I figured it was likely somewhere around a wash, so I’m going to program a bot to look for all Z’s unbans and reban them.

Other possible bot features I might like are the ability to nuke someone’s entire history with the server. Another person who left now has a crude name I wouldn’t mind if it were gone.

Final Question: Not all bots need potentially dangerous permissions to run. What are some niche moderation bots you’ve seen/used?

Leave a Reply