forked from cswimr/SeaCogs
fix(aurora): pylint fixes
This commit is contained in:
parent
bb3da8d03b
commit
166f5bc1ea
5 changed files with 39 additions and 20 deletions
|
@ -1,4 +1,4 @@
|
||||||
from abc import ABC
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
@ -12,9 +12,6 @@ class CompositeMetaClass(type(commands.Cog), type(ABC)):
|
||||||
coexist with discord.py's metaclass
|
coexist with discord.py's metaclass
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Mixin(ABC):
|
class Mixin(ABC):
|
||||||
"""
|
"""
|
||||||
Base class for well behaved type hint detection with composite class.
|
Base class for well behaved type hint detection with composite class.
|
||||||
|
@ -26,3 +23,27 @@ class Mixin(ABC):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.config: Config
|
self.config: Config
|
||||||
self.bot: Red
|
self.bot: Red
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# configuration/commands.py #
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def aurora(self, ctx: commands.Context) -> None:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def aurora_config(self, ctx: commands.Context) -> None:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def aurora_import(self, ctx: commands.Context) -> None:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def aurora_import_aurora(self, ctx: commands.Context) -> None:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def aurora_import_galacticbot(self, ctx: commands.Context) -> None:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
|
@ -16,14 +16,12 @@ import discord
|
||||||
import humanize
|
import humanize
|
||||||
from discord.ext import tasks
|
from discord.ext import tasks
|
||||||
from pytimeparse2 import disable_dateutil, parse
|
from pytimeparse2 import disable_dateutil, parse
|
||||||
from redbot.core import app_commands, checks, commands, data_manager
|
from redbot.core import app_commands, commands, data_manager
|
||||||
from redbot.core.app_commands import Choice
|
from redbot.core.app_commands import Choice
|
||||||
from redbot.core.utils.chat_formatting import box, error, warning
|
from redbot.core.utils.chat_formatting import box, error, warning
|
||||||
|
|
||||||
from .abc import CompositeMetaClass
|
from .abc import CompositeMetaClass
|
||||||
from .configuration.commands import Configuration
|
from .configuration.commands import Configuration
|
||||||
from .importers.galacticbot import ImportGalacticBotView
|
|
||||||
from .importers.aurora import ImportAuroraView
|
|
||||||
from .utilities.config import config, register_config
|
from .utilities.config import config, register_config
|
||||||
from .utilities.database import connect, create_guild_table, fetch_case, mysql_log
|
from .utilities.database import connect, create_guild_table, fetch_case, mysql_log
|
||||||
from .utilities.factory import case_factory, changes_factory, evidenceformat_factory, message_factory
|
from .utilities.factory import case_factory, changes_factory, evidenceformat_factory, message_factory
|
||||||
|
@ -68,6 +66,7 @@ class Aurora(Configuration, commands.Cog, metaclass=CompositeMetaClass):
|
||||||
logger.warning("Invalid requester passed to red_delete_data_for_user: %s", requester)
|
logger.warning("Invalid requester passed to red_delete_data_for_user: %s", requester)
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
super().__init__()
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
register_config(config)
|
register_config(config)
|
||||||
disable_dateutil()
|
disable_dateutil()
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Configuration(Mixin):
|
||||||
|
|
||||||
@aurora_import.command(name="aurora")
|
@aurora_import.command(name="aurora")
|
||||||
@commands.admin()
|
@commands.admin()
|
||||||
async def auroraset_import_aurora(self, ctx: commands.Context):
|
async def aurora_import_aurora(self, ctx: commands.Context):
|
||||||
"""Import moderations from another bot using Aurora."""
|
"""Import moderations from another bot using Aurora."""
|
||||||
if ctx.message.attachments and ctx.message.attachments[0].content_type == 'application/json; charset=utf-8':
|
if ctx.message.attachments and ctx.message.attachments[0].content_type == 'application/json; charset=utf-8':
|
||||||
message = await ctx.send(warning("Are you sure you want to import moderations from another bot?\n**This will overwrite any moderations that already exist in this guild's moderation table.**\n*The import process will block the rest of your bot until it is complete.*"))
|
message = await ctx.send(warning("Are you sure you want to import moderations from another bot?\n**This will overwrite any moderations that already exist in this guild's moderation table.**\n*The import process will block the rest of your bot until it is complete.*"))
|
||||||
|
@ -36,7 +36,7 @@ class Configuration(Mixin):
|
||||||
|
|
||||||
@aurora_import.command(name="galacticbot")
|
@aurora_import.command(name="galacticbot")
|
||||||
@commands.admin()
|
@commands.admin()
|
||||||
async def auroraset_import_galacticbot(self, ctx: commands.Context):
|
async def aurora_import_galacticbot(self, ctx: commands.Context):
|
||||||
"""Import moderations from GalacticBot."""
|
"""Import moderations from GalacticBot."""
|
||||||
if ctx.message.attachments and ctx.message.attachments[0].content_type == 'application/json; charset=utf-8':
|
if ctx.message.attachments and ctx.message.attachments[0].content_type == 'application/json; charset=utf-8':
|
||||||
message = await ctx.send(warning("Are you sure you want to import GalacticBot moderations?\n**This will overwrite any moderations that already exist in this guild's moderation table.**\n*The import process will block the rest of your bot until it is complete.*"))
|
message = await ctx.send(warning("Are you sure you want to import GalacticBot moderations?\n**This will overwrite any moderations that already exist in this guild's moderation table.**\n*The import process will block the rest of your bot until it is complete.*"))
|
||||||
|
|
|
@ -9,13 +9,13 @@ from ..utilities.config import config
|
||||||
|
|
||||||
async def _core(ctx: commands.Context) -> Embed:
|
async def _core(ctx: commands.Context) -> Embed:
|
||||||
"""Generates the core embed for configuration menus to use."""
|
"""Generates the core embed for configuration menus to use."""
|
||||||
embed = Embed(
|
e = Embed(
|
||||||
title="Aurora Configuration Menu",
|
title="Aurora Configuration Menu",
|
||||||
description="Use the buttons below to configure Aurora.",
|
description="Use the buttons below to configure Aurora.",
|
||||||
color=await ctx.embed_color()
|
color=await ctx.embed_color()
|
||||||
)
|
)
|
||||||
embed.set_thumbnail(url=ctx.bot.user.display_avatar.url)
|
e.set_thumbnail(url=ctx.bot.user.display_avatar.url)
|
||||||
return embed
|
return e
|
||||||
|
|
||||||
async def _overrides(user: Union[Member, User]) -> str:
|
async def _overrides(user: Union[Member, User]) -> str:
|
||||||
"""Generates a configuration menu field value for a user's overrides."""
|
"""Generates a configuration menu field value for a user's overrides."""
|
||||||
|
@ -102,10 +102,10 @@ async def _immune(guild: Guild) -> str:
|
||||||
|
|
||||||
async def embed(ctx: commands.Context) -> Embed:
|
async def embed(ctx: commands.Context) -> Embed:
|
||||||
"""Generates the configuration embed for a guild."""
|
"""Generates the configuration embed for a guild."""
|
||||||
embed = await _core(ctx)
|
e = await _core(ctx)
|
||||||
embed.add_field(name="User Overrides", value=await _overrides(ctx.author), inline=False)
|
e.add_field(name="User Overrides", value=await _overrides(ctx.author), inline=False)
|
||||||
if ctx.guild is not None and (ctx.author.guild_permissions.administrator or ctx.author.guild_permissions.manage_guild):
|
if ctx.guild is not None and (ctx.author.guild_permissions.administrator or ctx.author.guild_permissions.manage_guild):
|
||||||
embed.add_field(name="Guild Settings", value=await _guild(ctx.guild), inline=False)
|
e.add_field(name="Guild Settings", value=await _guild(ctx.guild), inline=False)
|
||||||
embed.add_field(name="Blacklist Roles", value=await _blacklist(ctx.guild), inline=False)
|
e.add_field(name="Blacklist Roles", value=await _blacklist(ctx.guild), inline=False)
|
||||||
embed.add_field(name="Immune Roles", value=await _immune(ctx.guild), inline=False)
|
e.add_field(name="Immune Roles", value=await _immune(ctx.guild), inline=False)
|
||||||
return embed
|
return e
|
||||||
|
|
|
@ -6,7 +6,6 @@ def get_bool_emoji(value: bool) -> str:
|
||||||
return "\N{WHITE HEAVY CHECK MARK}"
|
return "\N{WHITE HEAVY CHECK MARK}"
|
||||||
if value is False:
|
if value is False:
|
||||||
return "\N{NO ENTRY SIGN}"
|
return "\N{NO ENTRY SIGN}"
|
||||||
if value is None:
|
|
||||||
return "\N{BLACK QUESTION MARK ORNAMENT}\N{VARIATION SELECTOR-16}"
|
return "\N{BLACK QUESTION MARK ORNAMENT}\N{VARIATION SELECTOR-16}"
|
||||||
|
|
||||||
def get_pagesize_str(value: Union[int, None]) -> str:
|
def get_pagesize_str(value: Union[int, None]) -> str:
|
||||||
|
|
Loading…
Reference in a new issue