From f969f7d3f1f91c65cb71bfba6b660ecd74ea3a55 Mon Sep 17 00:00:00 2001 From: profitroll Date: Fri, 25 Apr 2025 23:20:26 +0200 Subject: [PATCH] Removed language from PycordGuild --- classes/pycord_guild.py | 13 +------------ cogs/config.py | 14 +------------- locale/en-US.json | 5 +---- modules/utils/autocomplete_utils.py | 2 ++ 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/classes/pycord_guild.py b/classes/pycord_guild.py index 11765ae..771a601 100644 --- a/classes/pycord_guild.py +++ b/classes/pycord_guild.py @@ -17,7 +17,7 @@ logger: Logger = get_logger(__name__) class PycordGuild: """Dataclass of DB entry of a guild""" - __slots__ = ("_id", "id", "channel_id", "category_id", "timezone", "language") + __slots__ = ("_id", "id", "channel_id", "category_id", "timezone") __short_name__ = "guild" __collection__ = col_guilds @@ -26,7 +26,6 @@ class PycordGuild: channel_id: int | None category_id: int | None timezone: str - language: str | None @classmethod async def from_id( @@ -146,7 +145,6 @@ class PycordGuild: "channel_id": self.channel_id, "category_id": self.category_id, "timezone": self.timezone, - "language": self.language, } @staticmethod @@ -156,7 +154,6 @@ class PycordGuild: "channel_id": None, "category_id": None, "timezone": "UTC", - "language": None, } @staticmethod @@ -226,11 +223,3 @@ class PycordGuild: # TODO Add documentation async def reset_timezone(self, cache: Optional[Cache] = None) -> None: await self._remove(cache, "timezone") - - # TODO Add documentation - async def set_language(self, language: str, cache: Optional[Cache] = None) -> None: - await self._set(cache, language=language) - - # TODO Add documentation - async def reset_language(self, cache: Optional[Cache] = None) -> None: - await self._remove(cache, "language") diff --git a/cogs/config.py b/cogs/config.py index 187aac8..65426b2 100644 --- a/cogs/config.py +++ b/cogs/config.py @@ -13,7 +13,7 @@ from libbot.i18n import in_every_locale, _ from classes import PycordGuild from classes.pycord_bot import PycordBot -from modules.utils import autocomplete_languages, autocomplete_timezones +from modules.utils import autocomplete_timezones class Config(Cog): @@ -51,22 +51,12 @@ class Config(Cog): autocomplete=basic_autocomplete(autocomplete_timezones), required=True, ) - @option( - "language", - description=_("description", "commands", "config_set", "options", "language"), - description_localizations=in_every_locale( - "description", "commands", "config_set", "options", "language" - ), - autocomplete=basic_autocomplete(autocomplete_languages), - required=True, - ) async def command_config_set( self, ctx: ApplicationContext, category: CategoryChannel, channel: TextChannel, timezone: str, - language: str, ) -> None: guild: PycordGuild = await self.bot.find_guild(ctx.guild.id) @@ -83,7 +73,6 @@ class Config(Cog): channel_id=channel.id, category_id=category.id, timezone=str(timezone_parsed), - language=language, ) await ctx.respond(self.bot._("config_set", "messages", locale=ctx.locale)) @@ -129,7 +118,6 @@ class Config(Cog): channel_id=guild.channel_id, category_id=guild.category_id, timezone=guild.timezone, - language=guild.language, ) ) diff --git a/locale/en-US.json b/locale/en-US.json index f40daae..71d82f9 100644 --- a/locale/en-US.json +++ b/locale/en-US.json @@ -6,7 +6,7 @@ "timezone_invalid": "Timezone **{timezone}** was not found. Please, select one of the timezones provided by the autocompletion.", "config_set": "Configuration has been updated. You can review it anytime using `/config show`.", "config_reset": "Configuration has been reset. You can update it using `/config set`, otherwise no events can be held.", - "config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: {timezone}\nLanguage: {language}" + "config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: {timezone}" }, "commands": { "config": { @@ -23,9 +23,6 @@ }, "timezone": { "description": "Timezone in which events take place" - }, - "language": { - "description": "Language for bot's messages" } } }, diff --git a/modules/utils/autocomplete_utils.py b/modules/utils/autocomplete_utils.py index 94d26c0..e463b1c 100644 --- a/modules/utils/autocomplete_utils.py +++ b/modules/utils/autocomplete_utils.py @@ -5,6 +5,7 @@ from zoneinfo import ZoneInfo, available_timezones from bson import ObjectId from discord import AutocompleteContext, OptionChoice from pymongo import ASCENDING +from typing_extensions import deprecated from modules.database import col_events, col_stages, col_users @@ -15,6 +16,7 @@ async def autocomplete_timezones(ctx: AutocompleteContext) -> List[str]: return sorted(list(available_timezones())) +@deprecated async def autocomplete_languages(ctx: AutocompleteContext) -> List[str]: """Return locales supported by the bot"""