I decided to work on a little project over the winter break. Visualizing the data of Discord servers using Python modules and the API of the Mee6 Discord bot. You can view the full code here on GitHub.
I used Discord quite a bit over the winter break. With the number of servers members on Discord, I thought it would be interesting to visualize the top members of each server. So I set out to do so in Python.
Users will input a server identifier to be read by the program, which will then retrieve information about the server's members and visualize them according to different metrics including the breakdown of levels and distribution of levels.
I used multiple Python packages including
requests was used
to retrieve the data from the Mee6 bot API and read them into the program,
matplotlib were used to plot the
I wrote the program by first splitting it into three sections. The first section of code is meant to read in user configuration, then the second section reads in server information from the API. Finally the third section generates the graphs using the data.
The config file was to contain the information needed to generate graphs to the user's liking. Some of the parameters I included were the server id, number of members to plot, level categories, labels, metric, and CSV output.
The contents of the config file was parsed in
main.py, view it
on the repository here.
The Mee6 API
Through some research, I identified that the data that the Mee6 bot stores on the leaderboard of each server can be accessed through the undocumented API route. Detailed information on obtaining the server id is found here.
With that, I was able to slowly write code that parsed the data and plotted the charts found in the project.
The main challenge I ran into was the acquisition of server data, as native Discord requires you to be a member of the server to get it. Through the use of Mee6, a popular Discord bot used for server levelling, I was able to get the data. Mee6 displays leaderboard of the top server members on a generated website. By using the Mee6 API link, I was able to get to the json file containing the information for up to 999 server members.
requestspackage to retrieve information from API links