style(aurora): reformat with ruff
This commit is contained in:
parent
ab22b791d1
commit
df22f73d2e
8 changed files with 64 additions and 102 deletions
|
@ -32,24 +32,17 @@ def check_permissions(
|
|||
raise (KeyError)
|
||||
|
||||
for permission in permissions:
|
||||
if (
|
||||
not getattr(resolved_permissions, permission, False)
|
||||
and resolved_permissions.administrator is not True
|
||||
):
|
||||
if not getattr(resolved_permissions, permission, False) and resolved_permissions.administrator is not True:
|
||||
return permission
|
||||
|
||||
return False
|
||||
|
||||
|
||||
async def check_moddable(
|
||||
target: Union[User, Member], interaction: Interaction, permissions: list
|
||||
) -> bool:
|
||||
async def check_moddable(target: Union[User, Member], interaction: Interaction, permissions: list) -> bool:
|
||||
"""Checks if a moderator can moderate a target."""
|
||||
if check_permissions(interaction.client.user, permissions, guild=interaction.guild):
|
||||
await interaction.response.send_message(
|
||||
error(
|
||||
f"I do not have the `{permissions}` permission, required for this action."
|
||||
),
|
||||
error(f"I do not have the `{permissions}` permission, required for this action."),
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
|
@ -57,43 +50,30 @@ async def check_moddable(
|
|||
if await config.guild(interaction.guild).use_discord_permissions() is True:
|
||||
if check_permissions(interaction.user, permissions, guild=interaction.guild):
|
||||
await interaction.response.send_message(
|
||||
error(
|
||||
f"You do not have the `{permissions}` permission, required for this action."
|
||||
),
|
||||
error(f"You do not have the `{permissions}` permission, required for this action."),
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
|
||||
if interaction.user.id == target.id:
|
||||
await interaction.response.send_message(
|
||||
content="You cannot moderate yourself!", ephemeral=True
|
||||
)
|
||||
await interaction.response.send_message(content="You cannot moderate yourself!", ephemeral=True)
|
||||
return False
|
||||
|
||||
if target.bot:
|
||||
await interaction.response.send_message(
|
||||
content="You cannot moderate bots!", ephemeral=True
|
||||
)
|
||||
await interaction.response.send_message(content="You cannot moderate bots!", ephemeral=True)
|
||||
return False
|
||||
|
||||
if isinstance(target, Member):
|
||||
if interaction.user.top_role <= target.top_role and await config.guild(interaction.guild).respect_hierarchy() is True:
|
||||
await interaction.response.send_message(
|
||||
content=error(
|
||||
"You cannot moderate members with a higher role than you!"
|
||||
),
|
||||
content=error("You cannot moderate members with a higher role than you!"),
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
|
||||
if (
|
||||
interaction.guild.get_member(interaction.client.user.id).top_role
|
||||
<= target.top_role
|
||||
):
|
||||
if interaction.guild.get_member(interaction.client.user.id).top_role <= target.top_role:
|
||||
await interaction.response.send_message(
|
||||
content=error(
|
||||
"You cannot moderate members with a role higher than the bot!"
|
||||
),
|
||||
content=error("You cannot moderate members with a role higher than the bot!"),
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
|
@ -118,9 +98,7 @@ async def get_next_case_number(guild_id: str, cursor=None) -> int:
|
|||
if not cursor:
|
||||
database = connect()
|
||||
cursor = database.cursor()
|
||||
cursor.execute(
|
||||
f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1"
|
||||
)
|
||||
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
||||
result = cursor.fetchone()
|
||||
return (result[0] + 1) if result else 1
|
||||
|
||||
|
@ -171,7 +149,6 @@ async def fetch_user_dict(client: commands.Bot, user_id: str) -> dict:
|
|||
"discriminator": "0",
|
||||
}
|
||||
|
||||
|
||||
return user_dict
|
||||
|
||||
|
||||
|
@ -216,9 +193,7 @@ async def log(interaction: Interaction, moderation_id: int, resolved: bool = Fal
|
|||
|
||||
case = await fetch_case(moderation_id, interaction.guild.id)
|
||||
if case:
|
||||
embed = await log_factory(
|
||||
interaction=interaction, case_dict=case, resolved=resolved
|
||||
)
|
||||
embed = await log_factory(interaction=interaction, case_dict=case, resolved=resolved)
|
||||
try:
|
||||
await logging_channel.send(embed=embed)
|
||||
except Forbidden:
|
||||
|
@ -229,11 +204,7 @@ async def send_evidenceformat(interaction: Interaction, case_dict: dict) -> None
|
|||
"""This function sends an ephemeral message to the moderator who took the moderation action, with a pre-made codeblock for use in the mod-evidence channel."""
|
||||
from .factory import evidenceformat_factory
|
||||
|
||||
send_evidence_bool = (
|
||||
await config.user(interaction.user).auto_evidenceformat()
|
||||
or await config.guild(interaction.guild).auto_evidenceformat()
|
||||
or False
|
||||
)
|
||||
send_evidence_bool = await config.user(interaction.user).auto_evidenceformat() or await config.guild(interaction.guild).auto_evidenceformat() or False
|
||||
if send_evidence_bool is False:
|
||||
return
|
||||
|
||||
|
@ -286,12 +257,14 @@ def create_pagesize_options() -> list[SelectOption]:
|
|||
)
|
||||
return options
|
||||
|
||||
|
||||
def timedelta_from_relativedelta(relativedelta: rd) -> td:
|
||||
"""Converts a relativedelta object to a timedelta object."""
|
||||
now = datetime.now()
|
||||
then = now - relativedelta
|
||||
return now - then
|
||||
|
||||
|
||||
def get_footer_image(coginstance: commands.Cog) -> File:
|
||||
"""Returns the footer image for the embeds."""
|
||||
image_path = data_manager.bundled_data_path(coginstance) / "arrow.png"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue