diff --git a/moderation/importers/galacticbot.py b/moderation/importers/galacticbot.py index c2d686c..e72b0b5 100644 --- a/moderation/importers/galacticbot.py +++ b/moderation/importers/galacticbot.py @@ -1,9 +1,12 @@ -from datetime import timedelta import json +from datetime import timedelta + +from discord import ButtonStyle, Interaction, Message, ui from redbot.core import commands -from discord import Message, ButtonStyle, Interaction, ui + from ..utilities.database import connect, create_guild_table, mysql_log + class ImportGalacticBotView(ui.View): def __init__(self, timeout, ctx, message): super().__init__() diff --git a/moderation/importers/moderation.py b/moderation/importers/moderation.py index 6980eb7..28303f6 100644 --- a/moderation/importers/moderation.py +++ b/moderation/importers/moderation.py @@ -1,8 +1,10 @@ -from datetime import timedelta, datetime import json +from datetime import datetime, timedelta from typing import Dict + +from discord import ButtonStyle, Interaction, Message, ui from redbot.core import commands -from discord import Message, ButtonStyle, Interaction, ui + from ..utilities.database import connect, create_guild_table, mysql_log diff --git a/moderation/moderation.py b/moderation/moderation.py index 871a4f1..2775064 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -6,26 +6,26 @@ # |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_| import json -import time import os +import time from datetime import datetime, timedelta, timezone import discord import humanize import mysql.connector - from discord.ext import tasks from pytimeparse2 import disable_dateutil, parse from redbot.core import app_commands, checks, commands, data_manager from redbot.core.app_commands import Choice +from .importers.galacticbot import ImportGalacticBotView +from .importers.moderation import ImportModerationView from .utilities.config import config, register_config from .utilities.database import connect, create_guild_table, fetch_case, mysql_log from .utilities.embed_factory import embed_factory from .utilities.logger import logger -from .utilities.utils import check_conf, check_permissions, check_moddable, fetch_channel_dict, fetch_user_dict, generate_dict, log -from .importers.galacticbot import ImportGalacticBotView -from .importers.moderation import ImportModerationView +from .utilities.utils import check_conf, check_moddable, check_permissions, fetch_channel_dict, fetch_user_dict, generate_dict, log + class Moderation(commands.Cog): """Custom moderation cog. diff --git a/moderation/utilities/database.py b/moderation/utilities/database.py index df47ab7..53e319f 100644 --- a/moderation/utilities/database.py +++ b/moderation/utilities/database.py @@ -3,11 +3,13 @@ import json import time from datetime import datetime + import mysql.connector from discord import Guild -from .utils import generate_dict, get_next_case_number, check_conf + from .config import config from .logger import logger +from .utils import check_conf, generate_dict, get_next_case_number async def connect(): diff --git a/moderation/utilities/embed_factory.py b/moderation/utilities/embed_factory.py index 4890911..b05c4d3 100644 --- a/moderation/utilities/embed_factory.py +++ b/moderation/utilities/embed_factory.py @@ -1,9 +1,12 @@ # pylint: disable=cyclic-import from datetime import datetime, timedelta + import humanize from discord import Color, Embed, Guild, Interaction, InteractionMessage -from .utils import get_next_case_number, fetch_user_dict, fetch_channel_dict + +from .utils import fetch_channel_dict, fetch_user_dict, get_next_case_number + async def embed_factory(embed_type: str, color: Color, /, interaction: Interaction = None, case_dict: dict = None, guild: Guild = None, reason: str = None, moderation_type: str = None, response: InteractionMessage = None, duration: timedelta = None, resolved: bool = False): """This method creates an embed from set parameters, meant for either moderation logging or contacting the moderated user. diff --git a/moderation/utilities/utils.py b/moderation/utilities/utils.py index 709a72e..322b2c8 100644 --- a/moderation/utilities/utils.py +++ b/moderation/utilities/utils.py @@ -2,9 +2,11 @@ import json from typing import Union -from discord import User, Member, Interaction, Guild -from discord.errors import NotFound, Forbidden + +from discord import Guild, Interaction, Member, User +from discord.errors import Forbidden, NotFound from redbot.core import commands + from .config import config @@ -199,8 +201,8 @@ async def fetch_role_dict(interaction: Interaction, role_id: str): async def log(interaction: Interaction, moderation_id: int, resolved: bool = False): """This method sends a message to the guild's configured logging channel when an infraction takes place.""" - from .embed_factory import embed_factory from .database import fetch_case + from .embed_factory import embed_factory logging_channel_id = await config.guild(interaction.guild).log_channel() if logging_channel_id != " ":