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