From 6a4b0cc30838842a67b07c726054090392985919 Mon Sep 17 00:00:00 2001 From: TrustyJAID Date: Fri, 30 Nov 2018 12:32:50 -0700 Subject: [PATCH] [Chatter] Fix attribute error when bot is messaged in DM (#43) Also allows you to talk to the bot in DM --- chatter/chat.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chatter/chat.py b/chatter/chat.py index 990fef5..e4cda92 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -186,15 +186,15 @@ class Chatter(Cog): for on_message recognition of @bot """ author = message.author - try: - guild: discord.Guild = message.guild - except AttributeError: # Not a guild message - return + guild: discord.Guild = message.guild channel: discord.TextChannel = message.channel if author.id != self.bot.user.id: - to_strip = "@" + guild.me.display_name + " " + if guild is None: + to_strip = "@" + channel.me.display_name + " " + else: + to_strip = "@" + guild.me.display_name + " " text = message.clean_content if not text.startswith(to_strip): return