Skip to content

Commit

Permalink
Fixes to SlashCommand.mention using qualified_id (#1672)
Browse files Browse the repository at this point in the history
* Implement qualified_id to fix command.mention

* Update discord/commands/core.py

Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>

Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
  • Loading branch information
NeloBlivion and BobDotCom authored Oct 6, 2022
1 parent 2bc364c commit 47a058b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,17 @@ def qualified_name(self) -> str:
else:
return self.name

@property
def qualified_id(self) -> int:
""":class:`int`: Retrieves the fully qualified command ID.
This is the root parent ID. For example, in ``/one two three``
the qualified ID would return ``one.id``.
"""
if self.id is None:
return self.parent.qualified_id
return self.id

def to_dict(self) -> dict[str, Any]:
raise NotImplementedError

Expand Down Expand Up @@ -821,7 +832,7 @@ def is_subcommand(self) -> bool:

@property
def mention(self) -> str:
return f"</{self.qualified_name}:{self.id}>"
return f"</{self.qualified_name}:{self.qualified_id}>"

def to_dict(self) -> dict:
as_dict = {
Expand Down

0 comments on commit 47a058b

Please sign in to comment.