Overview:
The discord bot utilizes discord.py v1.0 as an API wrapper to communicate with discord and is deployed via a docker container with an external connection to a networked database. The bot was originally created as a weekend project in late 2019 for use exclusively on my personal discord servers as a fun way of augmenting text chats with my friends on discord. Almost all the original code was rewritten in late 2020 when I decided to add the audio portion of the bot. The bot is separated into four cogs (Discord.py’s way of grouping related commands) and one head, the current cogs are the general cog, admin cog, audio cog and the twitter cog.
Design choices:
The first key design choice I made was the bot head which allows me to load, unload and reload cogs on the fly allowing for live updates to the cogs during runtime without downtime for any of the other cogs. The general cog handles all non-command messages, each time a member joins the server and handles the bot’s status. The audio cog allows the bot to play audio files in the voice channel of a discord server. The audio cog checks message attachments for mp3’s and downloads them for use in the bot. the bot stores all the audio files uploaded to it by their names and allows them to be played back at will as well as download and play the audio of any YouTube video. The audio cog also allows for pausing, resuming, stopping and volume changes. The admin cog holds commands that need to be restricted to admins its current use is to kill the bot remotely in case of a problem. The twitter cog was made as a joke so I will not discuss its full functionality, but it uses tweepy to access twitter and can get publicly available information about accounts, read recent tweets, and get tweeted images.
Takeaways:
I went into this project with no idea what it was going to be and no real plans for its future and I have learned the har way that is a terrible way to work on a project. Without a solid roadmap and clear achievable goals, I constantly lost focus on what I was working on looking to develop may portions of the bot simultaneously instead of polishing one feature at a time, as a result the bot is not in the condition I want it in. There are still vestiges of the original code that are poorly constructed, inefficient, or just outright broken and an otherwise cool project suffers from the remnants. As I learned from this project I need to stay focused on one project at a time so for now I leave this one as it is but ill be returning soon.