Exemplo n.º 1
0
 async def state(self):
     """Gets the server's current state"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     await self.bot.say("The server is **{}**".format(state))
Exemplo n.º 2
0
 async def list(self):
     """Gets the list of online players"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "offline":
         await self.bot.say("The server is offline")
         return
     await self.bot.say(amp.get_player_list())
Exemplo n.º 3
0
 async def kill(self):
     """Kills the server (useful if it isn't responding)"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "offline":
         await self.bot.say("The server is already stopped")
         return
     else:
         amp.control_power(amp.Power.KILL)
         await self.bot.say("Killing the server...")
Exemplo n.º 4
0
 async def restart(self):
     """Restarts the server"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "starting":
         await self.bot.say("The server is already starting")
         return
     elif state == "shutting down":
         await self.bot.say("The server is already shutting down")
         return
     else:
         amp.control_power(amp.Power.RESTART)
         await self.bot.say("Restarting the server...")
Exemplo n.º 5
0
 async def start(self):
     """Starts the server"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "online":
         await self.bot.say("The server is already running")
         return
     elif state == "starting":
         await self.bot.say("The server is already starting")
         return
     else:
         amp.control_power(amp.Power.START)
         await self.bot.say("Starting the server...")
Exemplo n.º 6
0
 async def sendcommand(self, ctx, *, command: str):
     """Send a console command"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "offline":
         await self.bot.say("The server is offline")
         return
     amp.send_console_command(command)
     console_logger.info("[Console Command] {}: {}".format(
         ctx.message.author,
         ctx.message.content.replace(
             "{}{} ".format(config.command_prefix, ctx.command), "")))
     await self.bot.say("Command sent!")
Exemplo n.º 7
0
async def on_ready():
    print("Connected! Logged in as {}/{}".format(bot.user, bot.user.id))
    amp.get_session_id()