Added a check to register to check for username changes and if the player is banned

If the username is not found in the applications, players is queried to find a matching player
is_banned property is now checked before adding them to the server
reminder
Joey Hines 2018-12-10 12:44:31 -06:00
parent 6a0d9d56e2
commit 03f5c87334
1 changed files with 16 additions and 7 deletions

View File

@ -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
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)
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):