示例#1
0
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)
示例#2
0
async def deactivate(session, serverID, ctx):
    # getting status
    status, title, content = await get_status(session, serverID)

    # only run deactivation when the server is ONLINE
    if status == 2:

        # get the number of players connected to the server
        num_players = await online_player_count(session, serverID)

        # there might still be people online!
        if num_players > 0:

            # check if member is Redstone/Guild admin
            if check_admin(ctx) == False:
                # won't force close if member isn't admin
                message = "There are still players connected to the server, can't shut it down now!\nOnly members with the `Redstone Admin` role can force close servers."
                return message

        # if:
        # there isn't anyone online...
        # OR if:
        # the member is Redstone/Guild admin...
        # then just keep going!
        await ctx.channel.send('Closing server... please wait.')

        # building stop url
        stop_url = 'https://ploudos.com/manage/s' + serverID + '/ajax2/stop'

        # performing GET request to accept_url to start up
        r_stop = await session.get(stop_url)

        html = await r_stop.text()

        # decoding JSON response text
        data = json.loads(html)
        print(data)

        if not data["error"]:
            print('No errors')
            message = 'Server halted! Check status with `!redstone status`.'
        else:
            message = 'Something went wrong! Please try again.'

    # else, just send the title as the message
    else:
        message = title

    return message
示例#3
0
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)
示例#4
0
async def setup(ctx, setupIP=None):
    # retrieving aiohttp ClientSession
    global session_list
    session = session_list[0]

    # 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)

    # run registration
    title, content = await register(ctx, session, guildID, guildName, is_admin,
                                    setupIP)

    if title != None:
        # format and send rich embed
        page = discord.Embed(title=title,
                             description=content,
                             colour=redstoneRed)
        await ctx.send(embed=page)
示例#5
0
async def setup(ctx):
  # retrieving aiohttp ClientSession
  global session_list
  session = session_list[0]

  # 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)

  # run registration

  # checking for valid argument
  try:
    setupIP = ctx.content.split()[2]    
  
  except:
    msg = ''
    msg += 'Invalid server address. The syntax for this command is:'
    msg += '```!redstone setup [IP address]\n\n[IP address] -> mycoolserver.ploudos.me```'

    await ctx.channel.send(msg)
    return

  
  title, content = await register(ctx, session, guildID, guildName, is_admin, setupIP)

  if title != None:
    # format and send rich embed
    page=discord.Embed(
      title=title,
      description=content + shutdown_warn,
      colour=embedColor
    )
    await ctx.channel.send(embed=page)