From 3dc6e6f99d11956c2b4474588612e76fc7a6bb38 Mon Sep 17 00:00:00 2001 From: Andrei Date: Tue, 18 Apr 2017 07:03:27 -0700 Subject: [PATCH] Fix possible edge case when bot has nickname and is mentioned Its valid for a user mention to be sent and parsed when a nickname mention is expected. As such we should filter both from the message contents to avoid message processing issues. --- disco/bot/bot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/disco/bot/bot.py b/disco/bot/bot.py index 8ad0fca..2631cb0 100644 --- a/disco/bot/bot.py +++ b/disco/bot/bot.py @@ -267,7 +267,10 @@ class Bot(LoggingClass): if msg.guild: member = msg.guild.get_member(self.client.state.me) if member: - content = content.replace(member.mention, '', 1) + # If nickname is set, filter both the normal and nick mentions + if member.nick: + content = content.replace(member.mention, '', 1) + content = content.replace(member.user.mention, '', 1) else: content = content.replace(self.client.state.me.mention, '', 1) elif mention_everyone: