Skip to content

Commit 47a058b

Browse files
Fixes to SlashCommand.mention using qualified_id (#1672)
* Implement qualified_id to fix command.mention * Update discord/commands/core.py Co-authored-by: BobDotCom <[email protected]> Co-authored-by: BobDotCom <[email protected]>
1 parent 2bc364c commit 47a058b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

discord/commands/core.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,17 @@ def qualified_name(self) -> str:
582582
else:
583583
return self.name
584584

585+
@property
586+
def qualified_id(self) -> int:
587+
""":class:`int`: Retrieves the fully qualified command ID.
588+
589+
This is the root parent ID. For example, in ``/one two three``
590+
the qualified ID would return ``one.id``.
591+
"""
592+
if self.id is None:
593+
return self.parent.qualified_id
594+
return self.id
595+
585596
def to_dict(self) -> dict[str, Any]:
586597
raise NotImplementedError
587598

@@ -821,7 +832,7 @@ def is_subcommand(self) -> bool:
821832

822833
@property
823834
def mention(self) -> str:
824-
return f"</{self.qualified_name}:{self.id}>"
835+
return f"</{self.qualified_name}:{self.qualified_id}>"
825836

826837
def to_dict(self) -> dict:
827838
as_dict = {

0 commit comments

Comments
 (0)