diff --git a/api/bot.py b/api/bot.py index 9275d34..91a4ad7 100644 --- a/api/bot.py +++ b/api/bot.py @@ -73,12 +73,18 @@ class Discord(discord.Client): nickname = player.username if not player.is_banned: - role = discord.utils.get(message.server.roles, name=self.member_role) - msg = "Successfully added {0} as a {1}.".format(nickname, self.member_role) + member = discord.utils.get(message.server.members, display_name=nickname) - yield from self.change_nickname(message.author, nickname) - yield from self.add_roles(message.author, role) - yield from self.discord_message(message.channel, msg) + if member is not None and member is not message.author: + msg = "{0}, a member with that name is already exists, please contact the staff".format(message.author.mention) + yield from self.discord_message(message.channel, msg) + else: + role = discord.utils.get(message.server.roles, name=self.member_role) + msg = "Successfully added {0} as a {1}.".format(nickname, self.member_role) + + yield from self.change_nickname(message.author, nickname) + yield from self.add_roles(message.author, role) + yield from self.discord_message(message.channel, msg) else: msg = "{0} You are currently banned, appeal on the subreddit.".format(message.author.mention)