mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 09:22:31 -05:00
Handle invalid locale configuration graciously during startup (#6517)
This commit is contained in:
@@ -115,7 +115,7 @@ class Red(
|
||||
owner=None,
|
||||
whitelist=[],
|
||||
blacklist=[],
|
||||
locale="en-US",
|
||||
locale=_i18n.FRESH_INSTALL_LOCALE,
|
||||
regional_format=None,
|
||||
embeds=True,
|
||||
color=15158332,
|
||||
@@ -1145,9 +1145,28 @@ class Red(
|
||||
self.owner_ids.add(self._owner_id_overwrite)
|
||||
|
||||
i18n_locale = await self._config.locale()
|
||||
_i18n.set_global_locale(i18n_locale)
|
||||
try:
|
||||
_i18n.set_global_locale(i18n_locale)
|
||||
except ValueError:
|
||||
log.warning(
|
||||
"The bot's global locale was set to an invalid value (%r)"
|
||||
" and will be reset to default (%s).",
|
||||
i18n_locale,
|
||||
_i18n.FRESH_INSTALL_LOCALE,
|
||||
)
|
||||
i18n_locale = _i18n.FRESH_INSTALL_LOCALE
|
||||
await self._config.locale.clear()
|
||||
i18n_regional_format = await self._config.regional_format()
|
||||
_i18n.set_global_regional_format(i18n_regional_format)
|
||||
try:
|
||||
_i18n.set_global_regional_format(i18n_regional_format)
|
||||
except ValueError:
|
||||
log.warning(
|
||||
"The bot's global regional format was set to an invalid value (%r)"
|
||||
" and will be reset to default (which is to inherit global locale, i.e. %s).",
|
||||
i18n_regional_format,
|
||||
i18n_locale,
|
||||
)
|
||||
await self._config.regional_format.clear()
|
||||
|
||||
async def _pre_connect(self) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user