Skip to content

Commit 2d1319f

Browse files
committed
Make group description Optional on decorators
1 parent 6d4cb00 commit 2d1319f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

discord/bot.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def command(self, **kwargs):
541541
def create_group(
542542
self,
543543
name: str,
544-
description: str,
544+
description: Optional[str] = None,
545545
guild_ids: Optional[List[int]] = None,
546546
) -> SlashCommandGroup:
547547
"""A shortcut method that creates a slash command group with no subcommands and adds it to the internal
@@ -553,7 +553,7 @@ def create_group(
553553
----------
554554
name: :class:`str`
555555
The name of the group to create.
556-
description: :class:`str`
556+
description: Optional[:class:`str`]
557557
The description of the group to create.
558558
guild_ids: Optional[List[:class:`int`]]
559559
A list of the IDs of each guild this group should be added to, making it a guild command.
@@ -564,14 +564,15 @@ def create_group(
564564
SlashCommandGroup
565565
The slash command group that was created.
566566
"""
567+
description = description or "No description provided."
567568
group = SlashCommandGroup(name, description, guild_ids)
568569
self.add_application_command(group)
569570
return group
570571

571572
def group(
572573
self,
573574
name: str,
574-
description: str,
575+
description: Optional[str] = None,
575576
guild_ids: Optional[List[int]] = None,
576577
) -> Callable[[Type[SlashCommandGroup]], SlashCommandGroup]:
577578
"""A shortcut decorator that initializes the provided subclass of :class:`.SlashCommandGroup`
@@ -583,7 +584,7 @@ def group(
583584
----------
584585
name: :class:`str`
585586
The name of the group to create.
586-
description: :class:`str`
587+
description: Optional[:class:`str`]
587588
The description of the group to create.
588589
guild_ids: Optional[List[:class:`int`]]
589590
A list of the IDs of each guild this group should be added to, making it a guild command.
@@ -595,7 +596,14 @@ def group(
595596
The slash command group that was created.
596597
"""
597598
def inner(cls: Type[SlashCommandGroup]) -> SlashCommandGroup:
598-
group = cls(name, description, guild_ids=guild_ids)
599+
group = cls(
600+
name,
601+
(
602+
description or inspect.cleandoc(cls.__doc__).splitlines()[0]
603+
if cls.__doc__ is not None else "No description provided"
604+
),
605+
guild_ids=guild_ids
606+
)
599607
self.add_application_command(group)
600608
return group
601609
return inner

0 commit comments

Comments
 (0)