visuals_bot.py
is a Python program that creates visual representations of Discord server member activity using pie charts. It is designed to be used as a Discord bot, and it generates and sends these visual representations in response to user commands. This README provides information on how to use the bot, its structure, and how to customize it for your needs.
- Creates pie charts that visualize Discord server member activity.
- Shows what members are playing in a server.
- Identifies members who are not currently engaged in any activity.
- The program can be easily extended to create other types of charts as needed.
Before using visuals_bot.py
, make sure you have the following dependencies installed:
-
Clone or download the repository containing
visuals_bot.py
andpiechart.py
. -
Create a Discord bot and obtain its token. You can follow the official guide on Creating a Bot Account to create a bot and retrieve its token.
-
Replace
"YOUR_BOT_TOKEN_HERE"
invisuals_bot.py
with your bot's token:token = "YOUR_BOT_TOKEN_HERE"
-
Customize the chart types and visuals as needed by modifying the
PieChart
orBarChart
classes inpiechart.py
, or extendingActivityChart
yourself with a different chart type. TheActivityChart
class serves as the base for creating different types of charts, just create a child class and define the method_create_visual(self)
that definesself.fig
as a plotly figure, then use it the same was as shown here with PieChart.
To use the visuals_bot.py
program, follow these steps:
-
Invite your bot to a Discord server.
-
Start the bot by running the
visuals_bot.py
script. -
In your Discord server, use the
/Activity
command to trigger the bot to create and send a pie chart visual representation of the member activity in the current channel. -
The bot will respond with the visual representation, showing what members are playing and how many are not engaged in any activity.
To add the PieChart feature to your own bot:
-
Copy
piechart.py
to your project folder. -
from piechart import PieChart
-
To send a piechart from your bot simply create a Piechart object by passing in a TextChannel (e.g. the channel the command was used in), then you can use the .image attribute as simply as:
@client.event async def on_message(message): if message.content.startswith('/Activity'): visual = PieChart(message.channel).image await message.channel.send(file=discord.File(fp=visual, filename=f'{message.guild.name}.png'))
The ActivityChart
class in piechart.py
can be extended to create other types of charts or visual representations. You can build upon the existing code to add new chart types and customize the visuals to suit your needs.