[Chatter] Fix attribute error when bot is messaged in DM

Also allows you to talk to the bot in DM
pull/43/head
TrustyJAID 6 years ago
parent c51e4f62d3
commit 5e3aa488ae
No known key found for this signature in database
GPG Key ID: AF24FAD20DF6BD3C

@ -186,14 +186,14 @@ 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:
if guild is None:
to_strip = "@" + channel.me.display_name + " "
else:
to_strip = "@" + guild.me.display_name + " " 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):

Loading…
Cancel
Save