-
Notifications
You must be signed in to change notification settings - Fork 0
/
visuals_bot.py
31 lines (22 loc) · 884 Bytes
/
visuals_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""This module defines a Discord bot that will read guild data and send back a visual representation."""
import os
import discord
from piechart import PieChart
intents = discord.Intents.all()
client = discord.Client(intents=intents)
@client.event
async def on_ready():
"""Will be called when the bot logs in."""
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
"""Will be called when a message is sent to a guild the bot is a member in."""
if message.author == client.user:
return
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'))
TOKEN = "YOUR-TOKEN-HERE"
if TOKEN == "YOUR-TOKEN-HERE": # If no token entered
TOKEN = os.getenv('TOKEN')
client.run(TOKEN)