Handle bot only content

Send a message when the history only has content from bots
This commit is contained in:
James
2018-10-27 11:17:55 +13:00
committed by GitHub
parent 77e143658d
commit 5c7fd7f9c8

View File

@@ -103,6 +103,7 @@ class Chatchart(BaseCog):
return await ctx.send("No permissions to read that channel.")
msg_data = {"total count": 0, "users": {}}
for msg in history:
if len(msg.author.name) >= 20:
short_name = "{}...".format(msg.author.name[:20])
@@ -119,6 +120,12 @@ class Chatchart(BaseCog):
msg_data["users"][whole_name]["msgcount"] = 1
msg_data["total count"] += 1
if msg_data['users'] == {}:
await em.delete()
return await ctx.message.channel.send(f'Only bots have sent messages in {channel.mention}')
for usr in msg_data["users"]:
pd = float(msg_data["users"][usr]["msgcount"]) / float(msg_data["total count"])
msg_data["users"][usr]["percent"] = round(pd * 100, 1)