Removed language from PycordGuild
This commit is contained in:
@@ -17,7 +17,7 @@ logger: Logger = get_logger(__name__)
|
|||||||
class PycordGuild:
|
class PycordGuild:
|
||||||
"""Dataclass of DB entry of a guild"""
|
"""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"
|
__short_name__ = "guild"
|
||||||
__collection__ = col_guilds
|
__collection__ = col_guilds
|
||||||
|
|
||||||
@@ -26,7 +26,6 @@ class PycordGuild:
|
|||||||
channel_id: int | None
|
channel_id: int | None
|
||||||
category_id: int | None
|
category_id: int | None
|
||||||
timezone: str
|
timezone: str
|
||||||
language: str | None
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def from_id(
|
async def from_id(
|
||||||
@@ -146,7 +145,6 @@ class PycordGuild:
|
|||||||
"channel_id": self.channel_id,
|
"channel_id": self.channel_id,
|
||||||
"category_id": self.category_id,
|
"category_id": self.category_id,
|
||||||
"timezone": self.timezone,
|
"timezone": self.timezone,
|
||||||
"language": self.language,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -156,7 +154,6 @@ class PycordGuild:
|
|||||||
"channel_id": None,
|
"channel_id": None,
|
||||||
"category_id": None,
|
"category_id": None,
|
||||||
"timezone": "UTC",
|
"timezone": "UTC",
|
||||||
"language": None,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -226,11 +223,3 @@ class PycordGuild:
|
|||||||
# TODO Add documentation
|
# TODO Add documentation
|
||||||
async def reset_timezone(self, cache: Optional[Cache] = None) -> None:
|
async def reset_timezone(self, cache: Optional[Cache] = None) -> None:
|
||||||
await self._remove(cache, "timezone")
|
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")
|
|
||||||
|
@@ -13,7 +13,7 @@ from libbot.i18n import in_every_locale, _
|
|||||||
|
|
||||||
from classes import PycordGuild
|
from classes import PycordGuild
|
||||||
from classes.pycord_bot import PycordBot
|
from classes.pycord_bot import PycordBot
|
||||||
from modules.utils import autocomplete_languages, autocomplete_timezones
|
from modules.utils import autocomplete_timezones
|
||||||
|
|
||||||
|
|
||||||
class Config(Cog):
|
class Config(Cog):
|
||||||
@@ -51,22 +51,12 @@ class Config(Cog):
|
|||||||
autocomplete=basic_autocomplete(autocomplete_timezones),
|
autocomplete=basic_autocomplete(autocomplete_timezones),
|
||||||
required=True,
|
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(
|
async def command_config_set(
|
||||||
self,
|
self,
|
||||||
ctx: ApplicationContext,
|
ctx: ApplicationContext,
|
||||||
category: CategoryChannel,
|
category: CategoryChannel,
|
||||||
channel: TextChannel,
|
channel: TextChannel,
|
||||||
timezone: str,
|
timezone: str,
|
||||||
language: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
|
guild: PycordGuild = await self.bot.find_guild(ctx.guild.id)
|
||||||
|
|
||||||
@@ -83,7 +73,6 @@ class Config(Cog):
|
|||||||
channel_id=channel.id,
|
channel_id=channel.id,
|
||||||
category_id=category.id,
|
category_id=category.id,
|
||||||
timezone=str(timezone_parsed),
|
timezone=str(timezone_parsed),
|
||||||
language=language,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.respond(self.bot._("config_set", "messages", locale=ctx.locale))
|
await ctx.respond(self.bot._("config_set", "messages", locale=ctx.locale))
|
||||||
@@ -129,7 +118,6 @@ class Config(Cog):
|
|||||||
channel_id=guild.channel_id,
|
channel_id=guild.channel_id,
|
||||||
category_id=guild.category_id,
|
category_id=guild.category_id,
|
||||||
timezone=guild.timezone,
|
timezone=guild.timezone,
|
||||||
language=guild.language,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
"timezone_invalid": "Timezone **{timezone}** was not found. Please, select one of the timezones provided by the autocompletion.",
|
"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_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_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": {
|
"commands": {
|
||||||
"config": {
|
"config": {
|
||||||
@@ -23,9 +23,6 @@
|
|||||||
},
|
},
|
||||||
"timezone": {
|
"timezone": {
|
||||||
"description": "Timezone in which events take place"
|
"description": "Timezone in which events take place"
|
||||||
},
|
|
||||||
"language": {
|
|
||||||
"description": "Language for bot's messages"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -5,6 +5,7 @@ from zoneinfo import ZoneInfo, available_timezones
|
|||||||
from bson import ObjectId
|
from bson import ObjectId
|
||||||
from discord import AutocompleteContext, OptionChoice
|
from discord import AutocompleteContext, OptionChoice
|
||||||
from pymongo import ASCENDING
|
from pymongo import ASCENDING
|
||||||
|
from typing_extensions import deprecated
|
||||||
|
|
||||||
from modules.database import col_events, col_stages, col_users
|
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()))
|
return sorted(list(available_timezones()))
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated
|
||||||
async def autocomplete_languages(ctx: AutocompleteContext) -> List[str]:
|
async def autocomplete_languages(ctx: AutocompleteContext) -> List[str]:
|
||||||
"""Return locales supported by the bot"""
|
"""Return locales supported by the bot"""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user