Perform validation in on_connect
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s

This commit is contained in:
Nexus 2024-05-27 17:34:26 +01:00
parent 3a6f879c72
commit e49d271c80

View file

@ -112,6 +112,21 @@ class Client(commands.Bot):
self.web: typing.Optional[asyncio.Task] = None
self.uptime_thread = None
async def on_connect(self):
log.debug("Walking the following application commands: %r", list(self.walk_application_commands()))
for command in self.walk_application_commands():
log.debug("Checking %r", command)
try:
assert command.input_type is not None, "Input type was None!"
_ = command.to_dict()
except Exception as e:
log.error("Failed to convert %r to dict", command, exc_info=e)
self.remove_application_command(command)
else:
log.debug("Loaded command %r.", command)
log.info("Connected to Discord.")
super().on_connect()
async def start(self, token: str, *, reconnect: bool = True) -> None:
if CONFIG["jimmy"].get("uptime_kuma_url"):
self.uptime_thread = KumaThread(
@ -276,16 +291,4 @@ if __disabled:
else:
log.info("No commands to disable. Full steam ahead!")
log.debug("Walking the following application commands: %r", list(bot.walk_application_commands()))
for command in bot.walk_application_commands():
log.debug("Checking %r", command)
try:
assert command.input_type is not None, "Input type was None!"
d = command.to_dict()
except Exception as e:
log.error("Failed to convert %r to dict", command, exc_info=e)
bot.remove_application_command(command)
else:
log.debug("Loaded command %r.", command)
bot.run(CONFIG["jimmy"]["token"])