From bdda31307b2892c0aafa2b8eb5bcfad7316452a9 Mon Sep 17 00:00:00 2001 From: NextChai <75498301+NextChai@users.noreply.github.com> Date: Wed, 31 Aug 2022 01:28:39 -0400 Subject: [PATCH] [commands] Add GroupCog.group_extras to set Group.extras Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com> --- discord/ext/commands/cog.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 6112a2294..00a05ea9d 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -145,6 +145,12 @@ class CogMeta(type): than :class:`str`. Defaults to ``True``. .. versionadded:: 2.0 + group_extras: :class:`dict` + A dictionary that can be used to store extraneous data. + This is only applicable for :class:`GroupCog` instances. + The library will not touch any values or keys within this dictionary. + + .. versionadded:: 2.1 """ __cog_name__: str @@ -153,6 +159,7 @@ class CogMeta(type): __cog_group_description__: Union[str, app_commands.locale_str] __cog_group_nsfw__: bool __cog_group_auto_locale_strings__: bool + __cog_group_extras__: Dict[Any, Any] __cog_settings__: Dict[str, Any] __cog_commands__: List[Command[Any, ..., Any]] __cog_app_commands__: List[Union[app_commands.Group, app_commands.Command[Any, ..., Any]]] @@ -183,6 +190,7 @@ class CogMeta(type): attrs['__cog_group_name__'] = group_name attrs['__cog_group_nsfw__'] = kwargs.pop('group_nsfw', False) attrs['__cog_group_auto_locale_strings__'] = kwargs.pop('group_auto_locale_strings', True) + attrs['__cog_group_extras__'] = kwargs.pop('group_extras', {}) description = kwargs.pop('description', None) if description is None: @@ -306,6 +314,7 @@ class Cog(metaclass=CogMeta): guild_ids=getattr(cls, '__discord_app_commands_default_guilds__', None), guild_only=getattr(cls, '__discord_app_commands_guild_only__', False), default_permissions=getattr(cls, '__discord_app_commands_default_permissions__', None), + extras=cls.__cog_group_extras__, ) else: group = None