From 610edaeead7d2ee956f79e2dcc5af10ad0edea26 Mon Sep 17 00:00:00 2001 From: JohannesIBK Date: Sat, 13 Aug 2022 17:27:39 +0200 Subject: [PATCH] [commands] Add option to disable `auto_locale_strings` in GroupCog --- 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 5d7d1be34..6112a2294 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -138,6 +138,12 @@ class CogMeta(type): Whether the application command group is NSFW. This is only applicable for :class:`GroupCog` instances. By default, it's ``False``. + .. versionadded:: 2.0 + group_auto_locale_strings: :class:`bool` + If this is set to ``True``, then all translatable strings will implicitly + be wrapped into :class:`~discord.app_commands.locale_str` rather + than :class:`str`. Defaults to ``True``. + .. versionadded:: 2.0 """ @@ -146,6 +152,7 @@ class CogMeta(type): __cog_group_name__: Union[str, app_commands.locale_str] __cog_group_description__: Union[str, app_commands.locale_str] __cog_group_nsfw__: bool + __cog_group_auto_locale_strings__: bool __cog_settings__: Dict[str, Any] __cog_commands__: List[Command[Any, ..., Any]] __cog_app_commands__: List[Union[app_commands.Group, app_commands.Command[Any, ..., Any]]] @@ -175,6 +182,7 @@ class CogMeta(type): attrs['__cog_name__'] = cog_name 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) description = kwargs.pop('description', None) if description is None: @@ -293,6 +301,7 @@ class Cog(metaclass=CogMeta): name=cls.__cog_group_name__, description=cls.__cog_group_description__, nsfw=cls.__cog_group_nsfw__, + auto_locale_strings=cls.__cog_group_auto_locale_strings__, parent=None, guild_ids=getattr(cls, '__discord_app_commands_default_guilds__', None), guild_only=getattr(cls, '__discord_app_commands_guild_only__', False),