Merge branch 'master' of ZeroHD/MinecraftManagerDjango into master
commit
2f2981154c
46
api/bot.py
46
api/bot.py
|
@ -68,28 +68,40 @@ class Discord(discord.Client):
|
||||||
count = Player.objects.filter(username__iexact=search, application__accepted=True).count()
|
count = Player.objects.filter(username__iexact=search, application__accepted=True).count()
|
||||||
|
|
||||||
if count > 0:
|
if count > 0:
|
||||||
if count == 1:
|
count = Player.objects.filter(username__iexact=search, application__accepted=True).count()
|
||||||
player = Player.objects.filter(username__iexact=search, application__accepted=True).all()[0]
|
|
||||||
nickname = player.username
|
|
||||||
|
|
||||||
if not player.is_banned:
|
if count == 0:
|
||||||
member = discord.utils.get(message.server.members, display_name=nickname)
|
msg = "{0}, please join the server once before joining the discord.".format(message.author.mention)
|
||||||
|
yield from self.discord_message(message.channel, msg)
|
||||||
|
return
|
||||||
|
|
||||||
if member is not None and member is not message.author:
|
player = Player.objects.filter(username__iexact=search, application__accepted=True).all()[0]
|
||||||
msg = "{0}, a member with that name is already exists, please contact the staff".format(message.author.mention)
|
nickname = player.username
|
||||||
yield from self.discord_message(message.channel, msg)
|
|
||||||
else:
|
|
||||||
for role_id in self.new_member_roles:
|
|
||||||
role = discord.utils.get(message.server.roles, id=role_id)
|
|
||||||
yield from self.add_roles(message.author, role)
|
|
||||||
|
|
||||||
msg = "Successfully added {0} as a member".format(nickname)
|
if not player.is_banned:
|
||||||
|
on_server = False
|
||||||
|
for member in message.server.members:
|
||||||
|
if member is message.author:
|
||||||
|
continue
|
||||||
|
|
||||||
yield from self.change_nickname(message.author, nickname)
|
if member.display_name == nickname:
|
||||||
yield from self.discord_message(message.channel, msg)
|
on_server = True
|
||||||
else:
|
|
||||||
msg = "{0} You are currently banned.".format(message.author.mention)
|
if on_server:
|
||||||
|
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)
|
yield from self.discord_message(message.channel, msg)
|
||||||
|
else:
|
||||||
|
for role_id in self.new_member_roles:
|
||||||
|
role = discord.utils.get(message.server.roles, id=role_id)
|
||||||
|
yield from self.add_roles(message.author, role)
|
||||||
|
|
||||||
|
msg = "Successfully added {0} as a member".format(nickname)
|
||||||
|
|
||||||
|
yield from self.change_nickname(message.author, nickname)
|
||||||
|
yield from self.discord_message(message.channel, msg)
|
||||||
|
else:
|
||||||
|
msg = "{0} You are currently banned.".format(message.author.mention)
|
||||||
|
yield from self.discord_message(message.channel, msg)
|
||||||
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue