Bots has been very fascinating to me, whether they may be from Twitter or to Discord, a place where I really appreciate bots. Me and my friends like playing music in our servers and so, I decided to try and create my personal bot using what I've learned in Python!
Muni Bot is my own personal bot. It's not that complex as it currently has limited features for now. I made it so that it can say hello to the users, let the users pet Muni, make Muni sit and smile, and ofcourse, play music! Believe it or not, Muni is a great singer! But for the current version of the bot, Muni can only sing songs from Youtube. But soon enough, I will also teach Muni to sing Spotify songs! The interactions that you can do with Muni is very goofy and fun. After all, Muni the dog only wants to make our hearts melt and our faces smile!
For this project, Python is the primary driving language for all the functionalities. But it was necessary for me to use libraries to help make the bot. I used the following libraries:
- Discord
- Discord.py[voice]
- yt-dlp
- validator-collection
- pytest
- mock
The said libraries allowed me to add many functionalities to the Muni Bot!
I will give a rundown on the code itself. I first imported the said libraries and modules that I will later use for my functions. Then, I have a separate file containing the TOKEN key connecting my discord bot to my actual code. I placed it on a separate file to avoid my data getting leaked. Then, I declared a url_list dictionary which will later be used to store the songs to be played by Muni.
Afterwards, there are necessary codes need to be included in order for me to construct an object called client. These lines will allow me with control and access to the majority of possible functionalities. I also created a new class named Menu, which will be helpful whenever the user plays some music.
The following codes are the client event and command functionalities of my bot. They can be called whenever the user typed a keyword or if they add a dollar sign prefix to their commands. Some of these functions will say hi to the user, make Muni do cute things such as sitting, smiling, and the likes. The other functions are then made whenever Muni will sing! These include playing the music, fetching the youtube url link needed by the discord modules, adding the songs to a queue list using my previously declared dictionary, and having pause, resume, skip, and stop functionalities.
Lastly, I have several commands that can be called by the user so that they could see what are the commands that they could run using the Muni Bot.