Compare commits

..

No commits in common. "858a1bae8a61621d78b9e6260dfb3c2a14207e97" and "dd9e221e2d964f51541f4d05674620c5930e873a" have entirely different histories.

12 changed files with 57 additions and 52 deletions

View file

@ -84,7 +84,7 @@ class Aurora(commands.Cog):
self.bot = bot
register_config(config)
disable_dateutil()
self.handle_expiry.start()
self.handle_expiry.start() # pylint: disable=no-member
async def cog_load(self):
"""This method prepares the database schema for all of the guilds the bot is currently in."""
@ -99,7 +99,7 @@ class Aurora(commands.Cog):
return
async def cog_unload(self):
self.handle_expiry.cancel()
self.handle_expiry.cancel() # pylint: disable=no-member
@commands.Cog.listener("on_guild_join")
async def db_generate_guild_join(self, guild: discord.Guild):

View file

@ -9,6 +9,7 @@ from redbot.core.utils.chat_formatting import box, warning
from ..utilities.database import connect, create_guild_table, mysql_log
# pylint: disable=duplicate-code
class ImportAuroraView(ui.View):
def __init__(self, timeout, ctx, message):
super().__init__()
@ -18,7 +19,7 @@ class ImportAuroraView(ui.View):
@ui.button(label="Yes", style=ButtonStyle.success)
async def import_button_y(
self, interaction: Interaction, button: ui.Button
):
): # pylint: disable=unused-argument
await self.message.delete()
await interaction.response.send_message(
"Deleting original table...", ephemeral=True
@ -40,7 +41,7 @@ class ImportAuroraView(ui.View):
await interaction.edit_original_response(content="Importing moderations...")
file = await self.ctx.message.attachments[0].read()
data: list[dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"])
data: [dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"])
user_mod_types = ["NOTE", "WARN", "MUTE", "UNMUTE", "KICK", "BAN", "UNBAN"]
@ -107,7 +108,7 @@ class ImportAuroraView(ui.View):
@ui.button(label="No", style=ButtonStyle.danger)
async def import_button_n(
self, interaction: Interaction, button: ui.Button
):
): # pylint: disable=unused-argument
await self.message.edit(content="Import cancelled.", view=None)
await self.message.delete(10)
await self.ctx.message.delete(10)

View file

@ -8,6 +8,7 @@ from redbot.core.utils.chat_formatting import box, warning
from ..utilities.database import connect, create_guild_table, mysql_log
# pylint: disable=duplicate-code
class ImportGalacticBotView(ui.View):
def __init__(self, timeout, ctx, message):
super().__init__()
@ -17,7 +18,7 @@ class ImportGalacticBotView(ui.View):
@ui.button(label="Yes", style=ButtonStyle.success)
async def import_button_y(
self, interaction: Interaction, button: ui.Button
):
): # pylint: disable=unused-argument
await self.message.delete()
await interaction.response.send_message(
"Deleting original table...", ephemeral=True
@ -150,7 +151,7 @@ class ImportGalacticBotView(ui.View):
@ui.button(label="No", style=ButtonStyle.danger)
async def import_button_n(
self, interaction: Interaction, button: ui.Button
):
): # pylint: disable=unused-argument
await self.message.edit(content="Import cancelled.", view=None)
await self.message.delete(10)
await self.ctx.message.delete(10)

View file

@ -1,11 +1,9 @@
from discord import ButtonStyle, Interaction, ui
from discord import ButtonStyle, ui, Interaction
from redbot.core import commands
from redbot.core.utils.chat_formatting import error
from aurora.utilities.config import config
from aurora.utilities.factory import addrole_embed
from aurora.utilities.config import config
class Addrole(ui.View):
def __init__(self, ctx: commands.Context):
@ -27,7 +25,7 @@ class Addrole(ui.View):
await interaction.message.edit(embed=await addrole_embed(self.ctx))
@ui.button(label="Clear", style=ButtonStyle.red, row=1)
async def clear(self, interaction: Interaction, button: ui.Button):
async def clear(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(error("You must have the manage guild permission to clear the guild's addrole whitelist."), ephemeral=True)
return
@ -36,7 +34,7 @@ class Addrole(ui.View):
await interaction.message.edit(embed=await addrole_embed(self.ctx))
@ui.button(label="Close", style=ButtonStyle.gray)
async def close(self, interaction: Interaction, button: ui.Button):
async def close(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(error("You can't do that!"), ephemeral=True)
return

View file

@ -1,11 +1,9 @@
from discord import ButtonStyle, Interaction, ui
from discord import ui, ButtonStyle, Interaction
from redbot.core import commands
from aurora.utilities.config import config
from aurora.utilities.factory import guild_embed
from aurora.utilities.utils import create_pagesize_options
from aurora.utilities.config import config
class Guild(ui.View):
def __init__(self, ctx: commands.Context):
@ -13,7 +11,7 @@ class Guild(ui.View):
self.ctx = ctx
@ui.button(label="Show Moderator", style=ButtonStyle.green, row=0)
async def show_moderator(self, interaction: Interaction, button: ui.Button):
async def show_moderator(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -23,7 +21,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="Use Discord Permissions", style=ButtonStyle.green, row=0)
async def use_discord_permissions(self, interaction: Interaction, button: ui.Button):
async def use_discord_permissions(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -33,7 +31,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="Ignore Modlog", style=ButtonStyle.green, row=0)
async def ignore_modlog(self, interaction: Interaction, button: ui.Button):
async def ignore_modlog(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -43,7 +41,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="Ignore Other Bots", style=ButtonStyle.green, row=0)
async def ignore_other_bots(self, interaction: Interaction, button: ui.Button):
async def ignore_other_bots(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -53,7 +51,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="DM Users", style=ButtonStyle.green, row=1)
async def dm_users(self, interaction: Interaction, button: ui.Button):
async def dm_users(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -63,7 +61,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=1)
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button):
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -73,7 +71,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="Ephemeral", style=ButtonStyle.green, row=1)
async def ephemeral(self, interaction: Interaction, button: ui.Button):
async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
@ -83,7 +81,7 @@ class Guild(ui.View):
await interaction.message.edit(embed=await guild_embed(self.ctx))
@ui.button(label="History Inline", style=ButtonStyle.green, row=1)
async def inline(self, interaction: Interaction, button: ui.Button):
async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return

View file

@ -1,11 +1,9 @@
from discord import ButtonStyle, Interaction, ui
from discord import ButtonStyle, ui, Interaction
from redbot.core import commands
from redbot.core.utils.chat_formatting import error
from aurora.utilities.config import config
from aurora.utilities.factory import immune_embed
from aurora.utilities.config import config
class Immune(ui.View):
def __init__(self, ctx: commands.Context):
@ -28,7 +26,7 @@ class Immune(ui.View):
await interaction.message.edit(embed=await immune_embed(self.ctx))
@ui.button(label="Clear", style=ButtonStyle.red, row=1)
async def clear(self, interaction: Interaction, button: ui.Button):
async def clear(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(error("You must have the manage guild permission to clear the guild's immune roles."), ephemeral=True)
return
@ -37,7 +35,7 @@ class Immune(ui.View):
await interaction.message.edit(embed=await immune_embed(self.ctx))
@ui.button(label="Close", style=ButtonStyle.gray)
async def close(self, interaction: Interaction, button: ui.Button):
async def close(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(error("You can't do that!"), ephemeral=True)
return

View file

@ -1,11 +1,9 @@
from discord import ButtonStyle, Interaction, ui
from discord import ui, ButtonStyle, Interaction
from redbot.core import commands
from aurora.utilities.config import config
from aurora.utilities.factory import overrides_embed
from aurora.utilities.utils import create_pagesize_options
from aurora.utilities.config import config
class Overrides(ui.View):
def __init__(self, ctx: commands.Context):
@ -13,7 +11,7 @@ class Overrides(ui.View):
self.ctx = ctx
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=0)
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button):
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if self.ctx.author != interaction.user:
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
return
@ -28,7 +26,7 @@ class Overrides(ui.View):
await interaction.message.edit(embed=await overrides_embed(self.ctx))
@ui.button(label="Ephemeral", style=ButtonStyle.green, row=0)
async def ephemeral(self, interaction: Interaction, button: ui.Button):
async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if self.ctx.author != interaction.user:
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
return
@ -43,7 +41,7 @@ class Overrides(ui.View):
await interaction.message.edit(embed=await overrides_embed(self.ctx))
@ui.button(label="Inline", style=ButtonStyle.green, row=0)
async def inline(self, interaction: Interaction, button: ui.Button):
async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
if self.ctx.author != interaction.user:
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
return

View file

@ -1,3 +1,5 @@
# pylint: disable=cyclic-import
import json
import sqlite3
import time
@ -85,8 +87,8 @@ async def create_guild_table(guild: Guild):
"NULL",
"NULL",
0,
json.dumps([]),
json.dumps({}),
json.dumps([]), # pylint: disable=dangerous-default-value
json.dumps({}), # pylint: disable=dangerous-default-value
)
cursor.execute(insert_query, insert_values)
@ -102,6 +104,7 @@ async def create_guild_table(guild: Guild):
database.close()
# pylint: disable=dangerous-default-value
async def mysql_log(
guild_id: str,
author_id: str,

View file

@ -1,13 +1,18 @@
# pylint: disable=cyclic-import
from datetime import datetime, timedelta
from typing import Union
import humanize
from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User
from discord import (Color, Embed, Guild, Interaction, InteractionMessage,
Member, Role, User)
from redbot.core import commands
from redbot.core.utils.chat_formatting import bold, box, error, warning
from aurora.utilities.config import config
from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str
from aurora.utilities.utils import (fetch_channel_dict, fetch_user_dict,
get_bool_emoji, get_next_case_number,
get_pagesize_str)
async def message_factory(

View file

@ -1,3 +1,5 @@
# pylint: disable=cyclic-import
import json
from datetime import timedelta as td
from typing import Union

View file

@ -17,6 +17,7 @@ from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import error, text_to_file
# pylint: disable=protected-access
class Backup(commands.Cog):
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
@ -129,7 +130,7 @@ class Backup(commands.Cog):
try:
repository = await downloader._repo_manager.add_repo(
url, name, branch
)
) # pylint: disable=protected-access
repo_s.append(
f"Added repository {name} from {url} on branch {branch}."
)
@ -141,7 +142,7 @@ class Backup(commands.Cog):
repo_e.append(f"Repository {name} already exists.")
repository = downloader._repo_manager.get_repo(
name
)
) # pylint: disable=protected-access
self.logger.debug("Repository %s already exists", name)
# This is commented out because errors.AuthenticationError is not yet implemented in Red 3.5.5's Downloader cog.
@ -199,7 +200,7 @@ class Backup(commands.Cog):
await ctx.bot.remove_loaded_package(cog)
await downloader._delete_cog(
poss_installed_path
)
) # pylint: disable=protected-access
uninstall_s.append(f"Uninstalled {cog}")
self.logger.debug("Uninstalled %s", cog)
else:
@ -207,7 +208,7 @@ class Backup(commands.Cog):
self.logger.warning("Failed to uninstall %s", cog)
await downloader._remove_from_installed(
cog_modules
)
) # pylint: disable=protected-access
for cog in cogs:
cog_name = cog["name"]
@ -228,14 +229,14 @@ class Backup(commands.Cog):
await downloader._filter_incorrect_cogs_by_names(
repository, [cog_name]
)
)
) # pylint: disable=protected-access
if not cogs_c:
install_e.append(message)
self.logger.error(message)
continue
failed_reqs = await downloader._install_requirements(
cogs_c
)
) # pylint: disable=protected-access
if failed_reqs:
install_e.append(
f"Failed to install {cog_name} due to missing requirements: {failed_reqs}"
@ -249,7 +250,7 @@ class Backup(commands.Cog):
installed_cogs, failed_cogs = await downloader._install_cogs(
cogs_c
)
) # pylint: disable=protected-access
if repository.available_libraries:
installed_libs, failed_libs = (
@ -270,7 +271,7 @@ class Backup(commands.Cog):
installed_cogs + installed_libs
if installed_libs
else installed_cogs
)
) # pylint: disable=protected-access
if installed_cogs:
installed_cog_name = installed_cogs[0].name
install_s.append(f"Installed {installed_cog_name}")

View file

@ -65,7 +65,7 @@ exclude = [
]
# Same as Black.
line-length = 320
line-length = 88
indent-width = 4
# Assume Python 3.11
@ -76,7 +76,7 @@ target-version = "py311"
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["F", "W", "E", "C901"]
ignore = ["C901"]
ignore = []
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]