Compare commits
No commits in common. "78630dc317a6819bb6a55d3c7b7cdbc1b9fc2568" and "ce48c1e8890900219c4e2d802c80ac0d0c94ab5c" have entirely different histories.
78630dc317
...
ce48c1e889
2 changed files with 23 additions and 32 deletions
|
@ -1,5 +1,6 @@
|
|||
# pylint: disable=duplicate-code
|
||||
import json
|
||||
from datetime import timedelta
|
||||
from time import time
|
||||
from typing import Dict
|
||||
|
||||
|
@ -9,7 +10,6 @@ from redbot.core.utils.chat_formatting import box, warning
|
|||
|
||||
from ..models.moderation import Moderation
|
||||
from ..utilities.database import connect, create_guild_table
|
||||
from ..utilities.utils import timedelta_from_string
|
||||
|
||||
|
||||
class ImportAuroraView(ui.View):
|
||||
|
@ -91,33 +91,31 @@ class ImportAuroraView(ui.View):
|
|||
metadata.update({"imported_timestamp": int(time())})
|
||||
|
||||
if case["duration"] != "NULL" and case["duration"] is not None:
|
||||
duration = timedelta_from_string(case["duration"])
|
||||
hours, minutes, seconds = map(int, case["duration"].split(":"))
|
||||
duration = timedelta(hours=hours, minutes=minutes, seconds=seconds)
|
||||
else:
|
||||
duration = None
|
||||
|
||||
try:
|
||||
Moderation.log(
|
||||
bot=interaction.client,
|
||||
guild_id=self.ctx.guild.id,
|
||||
moderator_id=case["moderator_id"],
|
||||
moderation_type=case["moderation_type"],
|
||||
target_type=case["target_type"],
|
||||
target_id=case["target_id"],
|
||||
role_id=case["role_id"],
|
||||
duration=duration,
|
||||
reason=case["reason"],
|
||||
timestamp=case["timestamp"],
|
||||
resolved=case["resolved"],
|
||||
resolved_by=case["resolved_by"],
|
||||
resolved_reason=case["resolve_reason"],
|
||||
expired=case["expired"],
|
||||
changes=changes,
|
||||
metadata=metadata,
|
||||
database=database,
|
||||
return_obj=False
|
||||
)
|
||||
except Exception as e:
|
||||
failed_cases.append(str(case["moderation_id"]) + f": {e}")
|
||||
Moderation.log(
|
||||
bot=interaction.client,
|
||||
guild_id=self.ctx.guild.id,
|
||||
moderator_id=case["moderator_id"],
|
||||
moderation_type=case["moderation_type"],
|
||||
target_type=case["target_type"],
|
||||
target_id=case["target_id"],
|
||||
role_id=case["role_id"],
|
||||
duration=duration,
|
||||
reason=case["reason"],
|
||||
timestamp=case["timestamp"],
|
||||
resolved=case["resolved"],
|
||||
resolved_by=case["resolved_by"],
|
||||
resolved_reason=case["resolve_reason"],
|
||||
expired=case["expired"],
|
||||
changes=changes,
|
||||
metadata=metadata,
|
||||
database=database,
|
||||
return_obj=False
|
||||
)
|
||||
|
||||
await interaction.edit_original_response(content="Import complete.")
|
||||
if failed_cases:
|
||||
|
|
|
@ -194,13 +194,6 @@ def timedelta_from_relativedelta(relativedelta: rd) -> timedelta:
|
|||
then = now - relativedelta
|
||||
return now - then
|
||||
|
||||
def timedelta_from_string(string: str) -> timedelta:
|
||||
"""Converts a string to a timedelta object."""
|
||||
from .logger import logger
|
||||
hours, minutes, seconds = map(int, string.split(":"))
|
||||
logger.debug("%s | hours: %s, minutes: %s, seconds: %s", string, hours, minutes, seconds)
|
||||
return timedelta(hours=hours, minutes=minutes, seconds=seconds)
|
||||
|
||||
def timedelta_to_string(timedelta: timedelta) -> str:
|
||||
"""Converts a timedelta object to a string."""
|
||||
hours, remainder = divmod(timedelta.seconds, 3600)
|
||||
|
|
Loading…
Add table
Reference in a new issue