Skip to content

Commit 3d1a96d

Browse files
feat: add slash command mentions
1 parent f28255a commit 3d1a96d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

disnake/ext/commands/base_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ def qualified_name(self) -> str:
249249
"""
250250
return self.name
251251

252+
@property
253+
def mention(self) -> str:
254+
# todo: add docs and make ID non-nullable
255+
return f"</{self.qualified_name}:{self.id}>"
256+
252257
@property
253258
def default_member_permissions(self) -> Optional[Permissions]:
254259
"""Optional[:class:`.Permissions`]: The default required member permissions for this command.

disnake/ext/commands/slash_core.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ def qualified_name(self) -> str:
192192
return self.name
193193
return f"{self._parent.qualified_name} {self.name}"
194194

195+
@property
196+
def mention(self) -> str:
197+
# todo: add docs and make ID non-nullable
198+
return f"</{self.qualified_name}:{self.id}>"
199+
200+
# todo: refactor this class to make this not optional
195201
@property
196202
def parent(self) -> Optional[InvokableSlashCommand]:
197203
"""Optional[:class:`InvokableSlashCommand`] The parent of this SubCommandGroup.
@@ -343,6 +349,11 @@ def qualified_name(self) -> str:
343349
return self.name
344350
return f"{self._parent.qualified_name} {self.name}"
345351

352+
@property
353+
def mention(self) -> str:
354+
# todo: add docs and make ID non-nullable
355+
return f"</{self.qualified_name}:{self.id}>"
356+
346357
@property
347358
def parent(self) -> Optional[Union[InvokableSlashCommand, SubCommandGroup]]:
348359
"""Optional[Union[:class:`InvokableSlashCommand`, :class:`SubCommandGroup`]]: The parent of this subcommand.

0 commit comments

Comments
 (0)