From 136a601e07ed8a727788296036a07a0852e70812 Mon Sep 17 00:00:00 2001 From: Kae Bartlett Date: Thu, 8 Feb 2024 19:03:29 +0000 Subject: [PATCH] Close bot with an error code if authentication has failed --- novus/api/gateway/gateway.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/novus/api/gateway/gateway.py b/novus/api/gateway/gateway.py index f623ce43..24599956 100644 --- a/novus/api/gateway/gateway.py +++ b/novus/api/gateway/gateway.py @@ -34,7 +34,12 @@ from ...enums import GatewayOpcode from ...flags import Intents from ...utils import MISSING -from .._errors import GatewayClose, GatewayClosed, GatewayException +from .._errors import ( + GatewayAuthenticationFailed, + GatewayClose, + GatewayClosed, + GatewayException, +) from .._route import Route from .dispatch import GatewayDispatch @@ -317,6 +322,9 @@ async def messages( self.running_tasks.add(t) t.add_done_callback(self.running_tasks.discard) return + except GatewayAuthenticationFailed: + log.info("[%s] Gateway authentication failed, closing with error code", self.shard_id) + exit(1) except GatewayException as e: log.debug("[%s] Generic gateway exception %s", self.shard_id, e, exc_info=e) t = asyncio.create_task(self.reconnect(resume=e.reconnect))