From 67c4975343fc5b0bbb261f42d4ffd8f31a00dbfa Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 23 Aug 2018 17:03:02 -0400 Subject: [PATCH] Some updates --- .gitignore | 2 ++ chatter/chat.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e6a15fa..9ec1673 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .idea/ *.pyc venv/ +v-data/ +database.sqlite3 diff --git a/chatter/chat.py b/chatter/chat.py index 276f6d8..38bafec 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -137,16 +137,21 @@ class Chatter: else: await ctx.send("Error occurred :(") - async def on_message(self, message): + async def on_message(self, message: discord.Message): """ Credit to https://github.com/Twentysix26/26-Cogs/blob/master/cleverbot/cleverbot.py for on_message recognition of @bot """ author = message.author - channel = message.channel + try: + guild: discord.Guild = message.guild + except AttributeError: # Not a guild message + return + + channel: discord.TextChannel = message.channel - if message.author.id != self.bot.user.id: - to_strip = "@" + author.guild.me.display_name + " " + if author.id != self.bot.user.id: + to_strip = "@" + guild.me.display_name + " " text = message.clean_content if not text.startswith(to_strip): return