forked from Minecraft/minecraft_manager
Removing register command from MCM
parent
caa7463b70
commit
bcfad87868
62
api/bot.py
62
api/bot.py
|
@ -55,68 +55,6 @@ class Discord(discord.Client):
|
||||||
# FIX STALE DB CONNECTIONS
|
# FIX STALE DB CONNECTIONS
|
||||||
close_old_connections()
|
close_old_connections()
|
||||||
|
|
||||||
# IF NOT A MEMBER YET
|
|
||||||
if len(member_roles) == 1:
|
|
||||||
# REGISTER
|
|
||||||
match = re.match("[{0}]register (\S+)?$".format(self.prefix), message.content)
|
|
||||||
if match:
|
|
||||||
search = match.group(1)
|
|
||||||
count = Application.objects.filter(username__iexact=search, accepted=True).count()
|
|
||||||
|
|
||||||
if count == 0:
|
|
||||||
count = Player.objects.filter(username__iexact=search, application__accepted=True).count()
|
|
||||||
|
|
||||||
if count > 0:
|
|
||||||
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:
|
|
||||||
on_server = False
|
|
||||||
for member in message.server.members:
|
|
||||||
if member is message.author:
|
|
||||||
continue
|
|
||||||
|
|
||||||
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:
|
|
||||||
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
|
|
||||||
else:
|
|
||||||
app = Application.objects.filter(username__iexact=search).first()
|
|
||||||
|
|
||||||
if app is None:
|
|
||||||
msg = "{0}, an application for {1} could not be found, please check your username and make sure you have applied.".format(message.author.mention, search)
|
|
||||||
elif app.accepted is None:
|
|
||||||
msg = "{0}, your application is still in review, please try again when you have been accepted on the server.".format(message.author.mention)
|
|
||||||
elif not app.accepted:
|
|
||||||
msg = "{0}, your application has been denied. Best of luck finding a new server!".format(message.author.mention)
|
|
||||||
else:
|
|
||||||
msg = "{0}, an error has occurred. Please try again in a few minutes.".format(message.author.mention)
|
|
||||||
|
|
||||||
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