mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Modlog API] Add resolution for people inpacted by bad casetypes (#3333)
* add resolution for people inpacted by bad casetypes * *some* amount of notice on this * Fine. * clearer warnings * actually, unnneded
This commit is contained in:
parent
7f2e5a0b70
commit
6219f0da67
@ -26,6 +26,13 @@ class ModLog(commands.Cog):
|
|||||||
"""Manage modlog settings."""
|
"""Manage modlog settings."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@checks.is_owner()
|
||||||
|
@modlogset.command(hidden=True, name="fixcasetypes")
|
||||||
|
async def reapply_audittype_migration(self, ctx: commands.Context):
|
||||||
|
"""Command to fix misbehaving casetypes."""
|
||||||
|
await modlog.handle_auditype_key()
|
||||||
|
await ctx.tick()
|
||||||
|
|
||||||
@modlogset.command()
|
@modlogset.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def modlog(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
async def modlog(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||||
|
|||||||
@ -142,6 +142,18 @@ async def _init(bot: Red):
|
|||||||
bot.add_listener(on_member_unban)
|
bot.add_listener(on_member_unban)
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_auditype_key():
|
||||||
|
all_casetypes = {
|
||||||
|
casetype_name: {
|
||||||
|
inner_key: inner_value
|
||||||
|
for inner_key, inner_value in casetype_data.items()
|
||||||
|
if inner_key != "audit_type"
|
||||||
|
}
|
||||||
|
for casetype_name, casetype_data in (await _conf.custom(_CASETYPES).all()).items()
|
||||||
|
}
|
||||||
|
await _conf.custom(_CASETYPES).set(all_casetypes)
|
||||||
|
|
||||||
|
|
||||||
async def _migrate_config(from_version: int, to_version: int):
|
async def _migrate_config(from_version: int, to_version: int):
|
||||||
if from_version == to_version:
|
if from_version == to_version:
|
||||||
return
|
return
|
||||||
@ -170,16 +182,7 @@ async def _migrate_config(from_version: int, to_version: int):
|
|||||||
await _conf.guild(cast(discord.Guild, discord.Object(id=guild_id))).clear_raw("cases")
|
await _conf.guild(cast(discord.Guild, discord.Object(id=guild_id))).clear_raw("cases")
|
||||||
|
|
||||||
if from_version < 3 <= to_version:
|
if from_version < 3 <= to_version:
|
||||||
all_casetypes = {
|
await handle_auditype_key()
|
||||||
casetype_name: {
|
|
||||||
inner_key: inner_value
|
|
||||||
for inner_key, inner_value in casetype_data.items()
|
|
||||||
if inner_key != "audit_type"
|
|
||||||
}
|
|
||||||
for casetype_name, casetype_data in (await _conf.custom(_CASETYPES).all()).items()
|
|
||||||
}
|
|
||||||
|
|
||||||
await _conf.custom(_CASETYPES).set(all_casetypes)
|
|
||||||
await _conf.schema_version.set(3)
|
await _conf.schema_version.set(3)
|
||||||
|
|
||||||
if from_version < 4 <= to_version:
|
if from_version < 4 <= to_version:
|
||||||
@ -507,8 +510,15 @@ class CaseType:
|
|||||||
self.image = image
|
self.image = image
|
||||||
self.case_str = case_str
|
self.case_str = case_str
|
||||||
self.guild = guild
|
self.guild = guild
|
||||||
|
|
||||||
|
if "audit_type" in kwargs:
|
||||||
|
kwargs.pop("audit_type", None)
|
||||||
|
log.warning(
|
||||||
|
"Fix this using the hidden command: `modlogset fixcasetypes` in Discord: "
|
||||||
|
"Got outdated key in casetype: audit_type"
|
||||||
|
)
|
||||||
if kwargs:
|
if kwargs:
|
||||||
log.warning("Got unexpected keys in case %s", ",".join(kwargs.keys()))
|
log.warning("Got unexpected key(s) in casetype: %s", ",".join(kwargs.keys()))
|
||||||
|
|
||||||
async def to_json(self):
|
async def to_json(self):
|
||||||
"""Transforms the case type into a dict and saves it"""
|
"""Transforms the case type into a dict and saves it"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user