Skip to content

Commit

Permalink
feat: add slash command mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Jul 28, 2022
1 parent e33c827 commit 4ae21f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions disnake/ext/commands/base_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ def qualified_name(self) -> str:
"""
return self.name

@property
def mention(self) -> str:
# todo: add docs and make ID non-nullable
return f"</{self.qualified_name}:{self.id}>"

@property
def default_member_permissions(self) -> Optional[Permissions]:
"""Optional[:class:`.Permissions`]: The default required member permissions for this command.
Expand Down
11 changes: 11 additions & 0 deletions disnake/ext/commands/slash_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ def qualified_name(self) -> str:
return self.name
return f"{self._parent.qualified_name} {self.name}"

@property
def mention(self) -> str:
# todo: add docs and make ID non-nullable
return f"</{self.qualified_name}:{self.id}>"

# todo: refactor this class to make this not optional
@property
def parent(self) -> Optional[InvokableSlashCommand]:
"""Optional[:class:`InvokableSlashCommand`] The parent of this SubCommandGroup.
Expand Down Expand Up @@ -343,6 +349,11 @@ def qualified_name(self) -> str:
return self.name
return f"{self._parent.qualified_name} {self.name}"

@property
def mention(self) -> str:
# todo: add docs and make ID non-nullable
return f"</{self.qualified_name}:{self.id}>"

@property
def parent(self) -> Optional[Union[InvokableSlashCommand, SubCommandGroup]]:
"""Optional[Union[:class:`InvokableSlashCommand`, :class:`SubCommandGroup`]]: The parent of this subcommand.
Expand Down

0 comments on commit 4ae21f8

Please sign in to comment.