diff --git a/api/bot.py b/api/bot.py index df6a1e3..9275d34 100644 --- a/api/bot.py +++ b/api/bot.py @@ -64,22 +64,31 @@ class Discord(discord.Client): search = match.group(1) count = Application.objects.filter(username__iexact=search, accepted__exact=True).count() + if count == 0: + count = Player.objects.filter(username__iexact=search, application__accepted__exact=True).count() + if count > 0: if count == 1: - player = Application.objects.filter(username__iexact=search, accepted__exact=True).all().values()[0] - nickname = player["username"] + player = Player.objects.filter(username__iexact=search, application__accepted__exact=True).all()[0] + nickname = player.username - role = discord.utils.get(message.server.roles, name=self.member_role) - msg = "Successfully added {0} as a {1}.".format(nickname, self.member_role) + 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) - yield from self.change_nickname(message.author, nickname) - yield from self.add_roles(message.author, role) - yield from self.discord_message(message.channel, msg) + 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) + + yield from self.discord_message(message.channel, msg) return else: msg = "An application for {0} could not be found, please apply first.".format(search) yield from self.discord_message(message.channel, msg) + return # IF MEMBER IS NOT AUTHORIZED, IGNORE if not any(role in self.auth_roles for role in member_roles):