Browse Source

Unbind bound methods passed to Command constructor

Fixes #7600
pull/7651/head
Rapptz 3 years ago
parent
commit
333849e5a3
  1. 8
      discord/app_commands/commands.py

8
discord/app_commands/commands.py

@ -365,6 +365,14 @@ class Command(Generic[GroupT, P, T]):
self.parent: Optional[Group] = parent
self.binding: Optional[GroupT] = None
self.on_error: Optional[Error[GroupT]] = None
# Unwrap __self__ for bound methods
try:
self.binding = callback.__self__
self._callback = callback = callback.__func__
except AttributeError:
pass
self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__)
self._guild_ids: Optional[List[int]] = guild_ids or getattr(
callback, '__discord_app_commands_default_guilds__', None

Loading…
Cancel
Save