mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
[commands] Reassign app_command attribute on copy
Prior to this change it would re-create the HybridAppCommand on copy which had the consequence of clearing parameter related changes.
This commit is contained in:
parent
1232a1d2fd
commit
52fcaed79b
@ -136,6 +136,12 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
|||||||
copy.wrapped = self.wrapped
|
copy.wrapped = self.wrapped
|
||||||
return copy
|
return copy
|
||||||
|
|
||||||
|
def copy(self) -> Self:
|
||||||
|
bindings = {
|
||||||
|
self.binding: self.binding,
|
||||||
|
}
|
||||||
|
return self._copy_with(parent=self.parent, binding=self.binding, bindings=bindings)
|
||||||
|
|
||||||
async def _check_can_run(self, interaction: discord.Interaction) -> bool:
|
async def _check_can_run(self, interaction: discord.Interaction) -> bool:
|
||||||
# Hybrid checks must run like so:
|
# Hybrid checks must run like so:
|
||||||
# - Bot global check once
|
# - Bot global check once
|
||||||
@ -271,6 +277,10 @@ class HybridCommand(Command[CogT, P, T]):
|
|||||||
else:
|
else:
|
||||||
ctx.kwargs = await self.app_command._transform_arguments(interaction, interaction.namespace)
|
ctx.kwargs = await self.app_command._transform_arguments(interaction, interaction.namespace)
|
||||||
|
|
||||||
|
def _ensure_assignment_on_copy(self, other: Self) -> Self:
|
||||||
|
copy = super()._ensure_assignment_on_copy(other)
|
||||||
|
copy.app_command = self.app_command.copy()
|
||||||
|
return copy
|
||||||
|
|
||||||
class HybridGroup(Group[CogT, P, T]):
|
class HybridGroup(Group[CogT, P, T]):
|
||||||
r"""A class that is both an application command group and a regular text group.
|
r"""A class that is both an application command group and a regular text group.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user