async def exit(ctx): # getting the guildID guildID = str(ctx.guild.id) # retrieving aiohttp ClientSession global session_list session = session_list[0] # check if member is a Redstone/guild admin if check_admin(ctx) == False: await ctx.send( "Only members with the `Redstone Admin` role can use this command.\nThis is due to the fact that players sometimes have to wait *hours* before their server gets to the top of the PloudOS activation queue." ) return None # get server ID result = get_serverID(str(ctx.guild.id)) if result == False: await ctx.send( "This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`." ) return None else: serverID = result await ctx.send('Exiting queue... please wait.') message = await leave_queue(session, serverID, guildID) await ctx.send(message)
async def restart(ctx): # retrieving aiohttp ClientSession global session_list session = session_list[0] # checking if member is a Redstone User if check_user(ctx) == False: await ctx.send( "Only designated Redstone Users can use this command.\nPlease ask your Discord server admin to give you the `Redstone User` role." ) return None # get server ID result = get_serverID(str(ctx.guild.id)) if result == False: await ctx.send( "This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`." ) return None else: serverID = result await ctx.send('Reactivating server... please wait.') message = await reactivate(session, serverID) await ctx.send(message)
async def start(ctx): # retrieving aiohttp ClientSession global session_list session = session_list[0] # get discord guildID guildID = str(ctx.guild.id) # checking if member is a Redstone User if check_user(ctx) == False: await ctx.channel.send("Only designated Redstone Users can use this command.\nPlease ask your Discord server admin to give you the `Redstone User` role.") return None # get server ID result = get_serverID(guildID) if result == False: await ctx.send("This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`.") return None else: serverID = result # checking for valid argument try: arg = ctx.content.split()[2] if arg == '1': msg = 'Nuremberg selected.' else: raise Exception("Not a valid location!") except: msg = '' msg += 'Invalid location. The syntax for this command is:' msg += '```!redstone start [location]\n\n[location] = 1 -> Nuremberg, Germany```' await ctx.channel.send(msg) return # message await ctx.channel.send(msg + ' Activating server... please wait.') # get looping status for this Guild looping = get_looping(guildID) print("bot.py looping is..." + str(looping)) # yep, string, not boolean if looping == 'False': looping = True update_looping(guildID, looping) # start server activatation loop looping = await activate(ctx, session, serverID, arg, guildID) update_looping(guildID, looping) else: await ctx.channel.send('Activation already in progress!')
async def reset(ctx): # get server ID result = get_serverID(str(ctx.guild.id)) if result == False: await ctx.channel.send("This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`.") return None else: serverID = result # getting Discord guild ('server') ID guildID = str(ctx.guild.id) # getting Discord guild ('server') name guildName = str(ctx.guild.name) # checking if member is a guild admin is_admin = check_admin(ctx) message = await unregister(guildID, guildName, is_admin) await ctx.channel.send(message)
async def _list(message): # retrieving aiohttp ClientSession global session_list session = session_list[0] # get server ID result = get_serverID(str(message.guild.id)) if result == False: await message.channel.send("This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`.") return else: serverID = result # get online player list msg = await get_list(session, serverID, message) if msg != '': await(message.channel.send(msg)) return
async def stop(ctx): # retrieving aiohttp ClientSession global session_list session = session_list[0] # checking if member is a Redstone User if check_user(ctx) == False: await ctx.channel.send("Only designated Redstone Users can use this command.\nPlease ask your Discord server admin to give you the `Redstone User` role.") return None # get server ID result = get_serverID(str(ctx.guild.id)) if result == False: await ctx.channel.send("This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`.") return None else: serverID = result # check if there are people online, if member has admin, stop the server message = await deactivate(session, serverID, ctx) await ctx.channel.send(message)
async def status(ctx): # retrieving aiohttp ClientSession global session_list session = session_list[0] # get server ID result = get_serverID(str(ctx.guild.id)) if result == False: await ctx.send( "This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`." ) return None else: serverID = result # get server status status, title, content = await get_status(session, serverID) page = discord.Embed(title=title, description=content, colour=redstoneRed) await ctx.send(embed=page)
async def time(message): # retrieving aiohttp ClientSession global session_list session = session_list[0] # get server ID result = get_serverID(str(message.guild.id)) if result == False: await message.channel.send("This Discord server isn't linked to PloudOS yet. Use `!redstone setup [serverip]`.") return None else: serverID = result # get queue times title, content = await get_times(session, serverID) # format and send rich embed page=discord.Embed( title=title, description=content + shutdown_warn, colour=embedColor ) await message.channel.send(embed=page)