forked from cswimr/SeaCogs
fix(pterodactyl): do not log during startup/shutdown to avoid the console channel getting flooded and ratelimited
This commit is contained in:
parent
142336e233
commit
39ae8b5ea0
1 changed files with 9 additions and 6 deletions
|
@ -65,6 +65,7 @@ class Pterodactyl(commands.Cog):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
message = await websocket.recv()
|
message = await websocket.recv()
|
||||||
|
current_status = ''
|
||||||
if json.loads(message)['event'] in ['token expiring', 'token expired']:
|
if json.loads(message)['event'] in ['token expiring', 'token expired']:
|
||||||
self.logger.debug("Received token expiring/expired event. Refreshing token.")
|
self.logger.debug("Received token expiring/expired event. Refreshing token.")
|
||||||
websocket_credentials = client.servers.get_websocket(server_id)
|
websocket_credentials = client.servers.get_websocket(server_id)
|
||||||
|
@ -76,6 +77,7 @@ class Pterodactyl(commands.Cog):
|
||||||
self.logger.debug("Authentication successful")
|
self.logger.debug("Authentication successful")
|
||||||
|
|
||||||
if json.loads(message)['event'] == 'console output' and await self.config.console_channel() is not None:
|
if json.loads(message)['event'] == 'console output' and await self.config.console_channel() is not None:
|
||||||
|
if current_status != 'starting' and current_status != 'stopping' and current_status != 'restarting':
|
||||||
channel = self.bot.get_channel(await self.config.console_channel())
|
channel = self.bot.get_channel(await self.config.console_channel())
|
||||||
if channel is not None:
|
if channel is not None:
|
||||||
content = self.remove_ansi_escape_codes(json.loads(message)['args'][0][:1900])
|
content = self.remove_ansi_escape_codes(json.loads(message)['args'][0][:1900])
|
||||||
|
@ -84,6 +86,7 @@ class Pterodactyl(commands.Cog):
|
||||||
#TODO - Add pagification for long messages to prevent Discord API errors
|
#TODO - Add pagification for long messages to prevent Discord API errors
|
||||||
|
|
||||||
if json.loads(message)['event'] == 'status':
|
if json.loads(message)['event'] == 'status':
|
||||||
|
current_status = json.loads(message)['args'][0]
|
||||||
console = self.bot.get_channel(await self.config.console_channel())
|
console = self.bot.get_channel(await self.config.console_channel())
|
||||||
if console is not None:
|
if console is not None:
|
||||||
await console.send(f"Server status changed! `{json.loads(message)['args'][0]}`")
|
await console.send(f"Server status changed! `{json.loads(message)['args'][0]}`")
|
||||||
|
|
Loading…
Reference in a new issue