Perform validation in on_connect
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s
This commit is contained in:
parent
3a6f879c72
commit
e49d271c80
1 changed files with 15 additions and 12 deletions
27
src/main.py
27
src/main.py
|
@ -111,6 +111,21 @@ class Client(commands.Bot):
|
|||
super().__init__(*args, **kwargs)
|
||||
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"):
|
||||
|
@ -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"])
|
||||
|
|
Loading…
Reference in a new issue