feat(aurora): boilerplate for all currently added moderation types
This commit is contained in:
parent
a05e957dde
commit
8f0425456c
4 changed files with 201 additions and 21 deletions
|
@ -9,7 +9,9 @@ from redbot.core import commands, data_manager
|
|||
from redbot.core.utils.chat_formatting import warning
|
||||
|
||||
from ..models.moderation import Moderation
|
||||
from ..models.type import Type
|
||||
from ..utilities.json import dump
|
||||
from ..utilities.registry import type_registry
|
||||
from ..utilities.utils import create_guild_table, timedelta_from_string
|
||||
|
||||
|
||||
|
@ -40,23 +42,18 @@ class ImportAuroraView(ui.View):
|
|||
file = await self.ctx.message.attachments[0].read()
|
||||
data: list[dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"])
|
||||
|
||||
user_mod_types = ["NOTE", "WARN", "ADDROLE", "REMOVEROLE", "MUTE", "UNMUTE", "KICK", "TEMPBAN", "BAN", "UNBAN"]
|
||||
|
||||
channel_mod_types = ["SLOWMODE", "LOCKDOWN"]
|
||||
|
||||
failed_cases = []
|
||||
|
||||
for case in data:
|
||||
if case["moderation_id"] == 0:
|
||||
continue
|
||||
|
||||
moderation_type: Type = type_registry[str.lower(case["moderation_type"])]
|
||||
if "target_type" not in case or not case["target_type"]:
|
||||
if case["moderation_type"] in user_mod_types:
|
||||
case["target_type"] = "USER"
|
||||
elif case["moderation_type"] in channel_mod_types:
|
||||
case["target_type"] = "CHANNEL"
|
||||
if moderation_type.channel:
|
||||
case["target_type"] = "channel"
|
||||
else:
|
||||
case["target_type"] = "USER"
|
||||
case["target_type"] = "user"
|
||||
|
||||
if "role_id" not in case or not case["role_id"]:
|
||||
case["role_id"] = None
|
||||
|
@ -95,8 +92,8 @@ class ImportAuroraView(ui.View):
|
|||
bot=interaction.client,
|
||||
guild_id=self.ctx.guild.id,
|
||||
moderator_id=case["moderator_id"],
|
||||
moderation_type=case["moderation_type"],
|
||||
target_type=case["target_type"],
|
||||
moderation_type=moderation_type.key,
|
||||
target_type=case["target_type"].lower(),
|
||||
target_id=case["target_id"],
|
||||
role_id=case["role_id"],
|
||||
duration=duration,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue