Utilize Client.interaction_tree
This commit is contained in:
parent
3315270ff5
commit
d70de07a28
1 changed files with 31 additions and 28 deletions
|
@ -58,35 +58,38 @@ class EventMixin(MemberEventMixin, MessageEventMixin, ComponentEventMixin):
|
|||
"{}&permissions=8&scope=bot%20applications.commands".format(self.user.id)
|
||||
)
|
||||
|
||||
global_base_commands = {}
|
||||
guild_base_commands = {}
|
||||
global_context_menus = []
|
||||
guild_context_menus = []
|
||||
for cid in self.interactions:
|
||||
commands = self.interactions[cid]
|
||||
to_update = global_base_commands if cid == 0 else guild_base_commands
|
||||
for command in commands:
|
||||
if isinstance(commands[command], ContextMenu):
|
||||
if cid == 0:
|
||||
global_context_menus.append(command)
|
||||
else:
|
||||
guild_context_menus.append(command)
|
||||
continue
|
||||
full = command.split(" ")
|
||||
base = full[0]
|
||||
if base not in to_update:
|
||||
to_update[base] = {}
|
||||
if len(full) == 3:
|
||||
to_update[base][full[1]] = full[2]
|
||||
elif len(full) == 2:
|
||||
to_update[base][full[1]] = None
|
||||
global_base_commands = 0
|
||||
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)
|
||||
)
|
||||
|
||||
self.logger.info(
|
||||
"Loaded {:>2} global base slash commands".format(len(global_base_commands))
|
||||
)
|
||||
self.logger.info("Loaded {:>2} global context menus".format(len(global_context_menus)))
|
||||
self.logger.info("Loaded {:>2} guild base slash commands".format(len(guild_base_commands)))
|
||||
self.logger.info("Loaded {:>2} guild context menus".format(len(guild_context_menus)))
|
||||
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