Catch error if interaction_tree doesn't exist
This commit is contained in:
parent
adef0b4ab2
commit
a5126482bb
1 changed files with 30 additions and 27 deletions
|
@ -62,34 +62,37 @@ class EventMixin(MemberEventMixin, MessageEventMixin, ComponentEventMixin):
|
|||
guild_base_commands = 0
|
||||
global_context_menus = 0
|
||||
guild_context_menus = 0
|
||||
for cid in self.interaction_tree:
|
||||
if cid == 0:
|
||||
global_base_commands = sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if not isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
global_context_menus = sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
else:
|
||||
guild_base_commands += sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if not isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
guild_context_menus += sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
try:
|
||||
for cid in self.interaction_tree:
|
||||
if cid == 0:
|
||||
global_base_commands = sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if not isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
global_context_menus = sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
else:
|
||||
guild_base_commands += sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if not isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
guild_context_menus += sum(
|
||||
1
|
||||
for _ in self.interaction_tree[cid]
|
||||
if isinstance(self.interaction_tree[cid][_], ContextMenu)
|
||||
)
|
||||
self.logger.info("Loaded {:>3} global base slash commands".format(global_base_commands))
|
||||
self.logger.info("Loaded {:>3} global context menus".format(global_context_menus))
|
||||
self.logger.info("Loaded {:>3} guild base slash commands".format(guild_base_commands))
|
||||
self.logger.info("Loaded {:>3} guild context menus".format(guild_context_menus))
|
||||
except Exception:
|
||||
self.logger.error("interaction_tree not found, try updating NAFF")
|
||||
|
||||
self.logger.info("Loaded {:>3} global base slash commands".format(global_base_commands))
|
||||
self.logger.info("Loaded {:>3} global context menus".format(global_context_menus))
|
||||
self.logger.info("Loaded {:>3} guild base slash commands".format(guild_base_commands))
|
||||
self.logger.info("Loaded {:>3} guild context menus".format(guild_context_menus))
|
||||
self.logger.debug("Hitting Reminders for faster loads")
|
||||
_ = await Reminder.find().to_list(None)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue