[Chatter] Fix attribute error when bot is messaged in DM (#43)

Also allows you to talk to the bot in DM
pull/47/head
TrustyJAID 6 years ago committed by bobloy
parent c51e4f62d3
commit 6a4b0cc308

@ -186,15 +186,15 @@ class Chatter(Cog):
for on_message recognition of @bot for on_message recognition of @bot
""" """
author = message.author author = message.author
try: guild: discord.Guild = message.guild
guild: discord.Guild = message.guild
except AttributeError: # Not a guild message
return
channel: discord.TextChannel = message.channel channel: discord.TextChannel = message.channel
if author.id != self.bot.user.id: 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 text = message.clean_content
if not text.startswith(to_strip): if not text.startswith(to_strip):
return return

Loading…
Cancel
Save