forked from Minecraft/minecraft_manager
Fixed issues brought up in issue #15
+Fixed issue where Discord.util could have issue finding players on the server +Added an error message if no player record is foundreminder
parent
b09d4f69f6
commit
94350da9bd
18
api/bot.py
18
api/bot.py
|
@ -68,14 +68,26 @@ class Discord(discord.Client):
|
|||
count = Player.objects.filter(username__iexact=search, application__accepted=True).count()
|
||||
|
||||
if count > 0:
|
||||
if count == 1:
|
||||
count = Player.objects.filter(username__iexact=search, application__accepted=True).count()
|
||||
|
||||
if count == 0:
|
||||
msg = "{0}, please join the server once before joining the discord.".format(message.author.mention)
|
||||
yield from self.discord_message(message.channel, msg)
|
||||
return
|
||||
|
||||
player = Player.objects.filter(username__iexact=search, application__accepted=True).all()[0]
|
||||
nickname = player.username
|
||||
|
||||
if not player.is_banned:
|
||||
member = discord.utils.get(message.server.members, display_name=nickname)
|
||||
on_server = False
|
||||
for member in message.server.members:
|
||||
if member is message.author:
|
||||
continue
|
||||
|
||||
if member is not None and member is not message.author:
|
||||
if member.display_name == nickname:
|
||||
on_server = True
|
||||
|
||||
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)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue