mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 18:06:08 -05:00
[Core] Guild scoped I18n (#3896)
* Guild I18n Never again! * Finish off guild scoped i18n * Black formatting * Added guild only flags. * Fix missing import. * Added listing of guild i18n settings * Added API support * Added API support... properly! * Added API support... for realsies! * Auto-translate create_cases instances You're welcome cog creators! Jack talked me into this! * Fix get_regional_format to actually return properly * Cleanup `set showsettings` * Style pass * Update redbot/core/core_commands.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/core/events.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/core/core_commands.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Fix missing import * Improve caching * Removal of unneeded function * Fix some naming * IDFK anymore... * Reformat * Update redbot/core/settings_caches.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/core/settings_caches.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/core/settings_caches.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Remove line number * Fix global sets * Set contextual locale manually where needed * Reports cog is wonderful... * Update redbot/core/core_commands.py Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com> * Set contextual locale manually where needed in Mutes cog * s Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
This commit is contained in:
@@ -194,6 +194,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
||||
guild = self.bot.get_guild(g_id)
|
||||
if guild is None or await self.bot.cog_disabled_in_guild(self, guild):
|
||||
continue
|
||||
await i18n.set_contextual_locales_from_guild(self.bot, guild)
|
||||
for u_id in self._server_mutes[guild.id]:
|
||||
if self._server_mutes[guild.id][u_id]["until"] is None:
|
||||
continue
|
||||
@@ -295,6 +296,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
||||
|
||||
for guild_id, users in multiple_mutes.items():
|
||||
guild = self.bot.get_guild(guild_id)
|
||||
await i18n.set_contextual_locales_from_guild(self.bot, guild)
|
||||
for user, channels in users.items():
|
||||
if len(channels) > 1:
|
||||
task_name = f"server-unmute-channels-{guild_id}-{user}"
|
||||
@@ -461,6 +463,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
||||
a = set(after.roles)
|
||||
roles_removed = list(b - a)
|
||||
roles_added = list(a - b)
|
||||
await i18n.set_contextual_locales_from_guild(self.bot, guild)
|
||||
if mute_role in roles_removed:
|
||||
# send modlog case for unmute and remove from cache
|
||||
if guild.id not in self._server_mutes:
|
||||
@@ -511,6 +514,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
||||
"""
|
||||
if await self.bot.cog_disabled_in_guild(self, after.guild):
|
||||
return
|
||||
await i18n.set_contextual_locales_from_guild(self.bot, after.guild)
|
||||
if after.id in self._channel_mutes:
|
||||
before_perms: Dict[int, Dict[str, Optional[bool]]] = {
|
||||
o.id: {name: attr for name, attr in p} for o, p in before.overwrites.items()
|
||||
@@ -569,6 +573,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
||||
# user to globally rate limit the bot therefore we are not
|
||||
# going to support re-muting users via channel overwrites
|
||||
return
|
||||
await i18n.set_contextual_locales_from_guild(self.bot, guild)
|
||||
if guild.id in self._server_mutes:
|
||||
if member.id in self._server_mutes[guild.id]:
|
||||
role = guild.get_role(mute_role)
|
||||
|
||||
Reference in New Issue
Block a user