2024-02-28 10:58:57 -05:00
|
|
|
# pylint: disable=cyclic-import
|
2024-01-08 04:18:54 -05:00
|
|
|
from datetime import datetime, timedelta
|
2024-05-04 17:09:22 -04:00
|
|
|
from typing import Union
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-07-06 11:30:37 -04:00
|
|
|
from discord import Color, Embed, Guild, Interaction, Member, Message, Role, User
|
2024-01-16 09:23:45 -05:00
|
|
|
from redbot.core import commands
|
2024-06-04 00:04:11 -04:00
|
|
|
from redbot.core.bot import Red
|
2024-05-06 21:39:43 -04:00
|
|
|
from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-06 21:39:43 -04:00
|
|
|
from ..models.moderation import Moderation
|
|
|
|
from ..models.partials import PartialUser
|
2024-07-06 11:30:37 -04:00
|
|
|
from ..models.type import Type
|
2024-05-06 21:39:43 -04:00
|
|
|
from .config import config
|
2024-06-04 00:04:11 -04:00
|
|
|
from .utils import get_bool_emoji, get_pagesize_str
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-24 03:56:32 -04:00
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
async def message_factory(
|
2024-06-04 00:04:11 -04:00
|
|
|
bot: Red,
|
2024-02-02 11:21:56 -05:00
|
|
|
color: Color,
|
|
|
|
guild: Guild,
|
|
|
|
reason: str,
|
2024-07-06 11:30:37 -04:00
|
|
|
moderation_type: Type,
|
2024-05-06 21:04:08 -04:00
|
|
|
moderator: Union[Member, User] | None = None,
|
|
|
|
duration: timedelta | None = None,
|
2024-07-06 11:30:37 -04:00
|
|
|
response: Message | None = None,
|
2024-05-06 21:04:08 -04:00
|
|
|
role: Role | None = None,
|
2024-02-02 11:21:56 -05:00
|
|
|
) -> Embed:
|
2024-01-08 04:18:54 -05:00
|
|
|
"""This function creates a message from set parameters, meant for contacting the moderated user.
|
|
|
|
|
|
|
|
Args:
|
2024-06-04 00:04:11 -04:00
|
|
|
bot (Red): The bot instance.
|
2024-01-08 04:18:54 -05:00
|
|
|
color (Color): The color of the embed.
|
|
|
|
guild (Guild): The guild the moderation occurred in.
|
|
|
|
reason (str): The reason for the moderation.
|
2024-07-06 11:30:37 -04:00
|
|
|
moderation_type (Type): The type of moderation.
|
2024-01-08 04:18:54 -05:00
|
|
|
moderator (Union[Member, User], optional): The moderator who performed the moderation. Defaults to None.
|
|
|
|
duration (timedelta, optional): The duration of the moderation. Defaults to None.
|
2024-07-06 11:30:37 -04:00
|
|
|
response (Message, optional): The response message. Defaults to None.
|
2024-02-02 12:05:05 -05:00
|
|
|
role (Role, optional): The role that was added or removed. Defaults to None.
|
|
|
|
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
embed: The message embed.
|
|
|
|
"""
|
2024-07-06 11:53:39 -04:00
|
|
|
if response is not None and moderation_type.moderation_type not in [
|
2024-07-06 11:30:37 -04:00
|
|
|
"kick",
|
|
|
|
"ban",
|
|
|
|
"tempban",
|
|
|
|
"unban",
|
2024-02-02 11:21:56 -05:00
|
|
|
]:
|
2024-01-08 04:18:54 -05:00
|
|
|
guild_name = f"[{guild.name}]({response.jump_url})"
|
|
|
|
else:
|
|
|
|
guild_name = guild.name
|
|
|
|
|
2024-07-06 11:30:37 -04:00
|
|
|
if duration:
|
2024-03-08 15:01:24 -05:00
|
|
|
embed_duration = f" for {humanize_timedelta(timedelta=duration)}"
|
2024-01-08 04:18:54 -05:00
|
|
|
else:
|
|
|
|
embed_duration = ""
|
|
|
|
|
2024-07-06 11:30:37 -04:00
|
|
|
# if moderation_type.type == "note":
|
|
|
|
# embed_desc = "received a"
|
|
|
|
# elif moderation_type.type == "addrole":
|
|
|
|
# embed_desc = f"received the {role.name} role"
|
|
|
|
# title = "Role Added"
|
|
|
|
# verb = ""
|
|
|
|
# elif moderation_type.type == "removerole":
|
|
|
|
# embed_desc = f"lost the {role.name} role"
|
|
|
|
# title = "Role Removed"
|
|
|
|
# verb = ""
|
|
|
|
# else:
|
|
|
|
# embed_desc = "been"
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
embed = Embed(
|
2024-07-06 11:55:05 -04:00
|
|
|
title=str.title(moderation_type.verb),
|
2024-07-06 11:30:37 -04:00
|
|
|
description=f"You have {moderation_type.embed_desc} {moderation_type.verb}{embed_duration} in {guild_name}.",
|
2024-02-02 11:21:56 -05:00
|
|
|
color=color,
|
|
|
|
timestamp=datetime.now(),
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
if await config.guild(guild).show_moderator() and moderator is not None:
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.add_field(
|
|
|
|
name="Moderator", value=f"`{moderator.name} ({moderator.id})`", inline=False
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.add_field(name="Reason", value=f"`{reason}`", inline=False)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
if guild.icon.url is not None:
|
|
|
|
embed.set_author(name=guild.name, icon_url=guild.icon.url)
|
|
|
|
else:
|
|
|
|
embed.set_author(name=guild.name)
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.set_footer(
|
2024-06-05 01:11:18 -04:00
|
|
|
text=f"Case #{await Moderation.get_next_case_number(bot=bot, guild_id=guild.id):,}",
|
2024-05-03 21:35:29 -04:00
|
|
|
icon_url="attachment://arrow.png",
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
|
|
|
async def log_factory(
|
2024-07-06 11:30:37 -04:00
|
|
|
ctx: commands.Context, moderation: Moderation, resolved: bool = False
|
2024-02-02 11:21:56 -05:00
|
|
|
) -> Embed:
|
2024-01-08 04:18:54 -05:00
|
|
|
"""This function creates a log embed from set parameters, meant for moderation logging.
|
|
|
|
|
|
|
|
Args:
|
2024-07-06 11:30:37 -04:00
|
|
|
ctx (commands.Context): The ctx object.
|
2024-05-04 17:09:22 -04:00
|
|
|
moderation (aurora.models.Moderation): The moderation object.
|
2024-01-08 04:18:54 -05:00
|
|
|
resolved (bool, optional): Whether the case is resolved or not. Defaults to False.
|
|
|
|
"""
|
2024-05-04 17:09:22 -04:00
|
|
|
target = await moderation.get_target()
|
|
|
|
moderator = await moderation.get_moderator()
|
2024-01-08 04:18:54 -05:00
|
|
|
if resolved:
|
2024-02-02 11:21:56 -05:00
|
|
|
embed = Embed(
|
2024-05-04 16:54:12 -04:00
|
|
|
title=f"📕 Case #{moderation.id:,} Resolved",
|
2024-07-06 11:30:37 -04:00
|
|
|
color=await ctx.bot.get_embed_color(ctx.channel),
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 17:09:22 -04:00
|
|
|
resolved_by = await moderation.get_resolved_by()
|
2024-05-04 21:06:29 -04:00
|
|
|
embed.description = f"**Type:** {str.title(moderation.moderation_type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** <t:{moderation.unix_timestamp}> | <t:{moderation.unix_timestamp}:R>"
|
2024-05-04 16:54:12 -04:00
|
|
|
|
|
|
|
if moderation.duration is not None:
|
2024-02-02 11:21:56 -05:00
|
|
|
duration_embed = (
|
2024-05-04 16:54:12 -04:00
|
|
|
f"{humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.end_timestamp}:R>"
|
|
|
|
if not moderation.expired
|
|
|
|
else str(humanize_timedelta(timedelta=moderation.duration))
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
|
|
|
embed.description = (
|
|
|
|
embed.description
|
2024-05-04 16:54:12 -04:00
|
|
|
+ f"\n**Duration:** {duration_embed}\n**Expired:** {moderation.expired}"
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
|
|
|
|
2024-05-24 04:18:17 -04:00
|
|
|
if moderation.metadata.items():
|
|
|
|
for key, value in moderation.metadata.items():
|
|
|
|
embed.description += f"\n**{key.title()}:** {value}"
|
|
|
|
|
2024-05-04 16:54:12 -04:00
|
|
|
embed.add_field(name="Reason", value=box(moderation.reason), inline=False)
|
2024-02-02 11:21:56 -05:00
|
|
|
|
|
|
|
embed.add_field(
|
|
|
|
name="Resolve Reason",
|
2024-05-04 16:54:12 -04:00
|
|
|
value=f"Resolved by `{resolved_by.name}` ({resolved_by.id}) for:\n"
|
|
|
|
+ box(moderation.resolve_reason),
|
2024-02-02 11:21:56 -05:00
|
|
|
inline=False,
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
else:
|
2024-02-02 11:21:56 -05:00
|
|
|
embed = Embed(
|
2024-05-04 16:54:12 -04:00
|
|
|
title=f"📕 Case #{moderation.id:,}",
|
2024-07-06 11:30:37 -04:00
|
|
|
color=await ctx.bot.get_embed_color(ctx.channel),
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
2024-05-04 21:06:29 -04:00
|
|
|
embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** <t:{moderation.unix_timestamp}> | <t:{moderation.unix_timestamp}:R>"
|
2024-05-04 16:54:12 -04:00
|
|
|
|
|
|
|
if moderation.duration:
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.description = (
|
|
|
|
embed.description
|
2024-05-04 21:06:29 -04:00
|
|
|
+ f"\n**Duration:** {humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.unix_timestamp}:R>"
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
|
|
|
|
2024-05-24 04:18:17 -04:00
|
|
|
if moderation.metadata.items():
|
|
|
|
for key, value in moderation.metadata.items():
|
|
|
|
embed.description += f"\n**{key.title()}:** {value}"
|
|
|
|
|
2024-05-04 16:54:12 -04:00
|
|
|
embed.add_field(name="Reason", value=box(moderation.reason), inline=False)
|
2024-01-08 04:18:54 -05:00
|
|
|
return embed
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-04 17:31:16 -04:00
|
|
|
async def case_factory(interaction: Interaction, moderation: Moderation) -> Embed:
|
2024-01-08 04:18:54 -05:00
|
|
|
"""This function creates a case embed from set parameters.
|
|
|
|
|
|
|
|
Args:
|
2024-05-04 17:31:16 -04:00
|
|
|
interaction (discord.Interaction): The interaction object.
|
|
|
|
moderation (aurora.models.Moderation): The moderation object.
|
2024-01-08 04:18:54 -05:00
|
|
|
"""
|
2024-05-04 17:31:16 -04:00
|
|
|
target = await moderation.get_target()
|
|
|
|
moderator = await moderation.get_moderator()
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
embed = Embed(
|
2024-05-04 17:31:16 -04:00
|
|
|
title=f"📕 Case #{moderation.id:,}",
|
2024-02-02 11:21:56 -05:00
|
|
|
color=await interaction.client.get_embed_color(interaction.channel),
|
|
|
|
)
|
2024-05-04 21:20:05 -04:00
|
|
|
embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** `{target.name}` ({target.id})\n**Moderator:** `{moderator.name}` ({moderator.id})\n**Resolved:** {moderation.resolved}\n**Timestamp:** <t:{moderation.unix_timestamp}> | <t:{moderation.unix_timestamp}:R>"
|
2024-05-04 17:31:16 -04:00
|
|
|
|
|
|
|
if moderation.duration:
|
2024-02-02 11:21:56 -05:00
|
|
|
duration_embed = (
|
2024-05-04 21:06:29 -04:00
|
|
|
f"{humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.unix_timestamp}:R>"
|
2024-05-04 17:31:16 -04:00
|
|
|
if moderation.expired is False
|
|
|
|
else str(humanize_timedelta(timedelta=moderation.duration))
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
2024-05-04 17:31:16 -04:00
|
|
|
embed.description += f"\n**Duration:** {duration_embed}\n**Expired:** {moderation.expired}"
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.description += (
|
2024-05-04 17:31:16 -04:00
|
|
|
f"\n**Changes:** {len(moderation.changes) - 1}"
|
|
|
|
if moderation.changes
|
2024-02-02 11:21:56 -05:00
|
|
|
else "\n**Changes:** 0"
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 17:31:16 -04:00
|
|
|
if moderation.role_id:
|
|
|
|
role = await moderation.get_role()
|
|
|
|
embed.description += f"\n**Role:** {role.name}"
|
2024-05-03 21:42:02 -04:00
|
|
|
|
2024-05-04 17:31:16 -04:00
|
|
|
if moderation.metadata:
|
2024-05-24 04:15:27 -04:00
|
|
|
if moderation.metadata.get("imported_from"):
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.description += (
|
2024-05-04 17:31:16 -04:00
|
|
|
f"\n**Imported From:** {moderation.metadata['imported_from']}"
|
|
|
|
)
|
2024-05-24 04:15:27 -04:00
|
|
|
moderation.metadata.pop("imported_from")
|
|
|
|
if moderation.metadata.get("imported_timestamp"):
|
2024-05-04 17:31:16 -04:00
|
|
|
embed.description += (
|
|
|
|
f"\n**Imported Timestamp:** <t:{moderation.metadata['imported_timestamp']}> | <t:{moderation.metadata['imported_timestamp']}:R>"
|
2024-02-02 11:21:56 -05:00
|
|
|
)
|
2024-05-24 04:15:27 -04:00
|
|
|
moderation.metadata.pop("imported_timestamp")
|
|
|
|
if moderation.metadata.items():
|
|
|
|
for key, value in moderation.metadata.items():
|
|
|
|
embed.description += f"\n**{key.title()}:** {value}"
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-04 17:31:16 -04:00
|
|
|
embed.add_field(name="Reason", value=box(moderation.reason), inline=False)
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-04 17:31:16 -04:00
|
|
|
if moderation.resolved:
|
|
|
|
resolved_user = await moderation.get_resolved_by()
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.add_field(
|
|
|
|
name="Resolve Reason",
|
2024-05-04 21:20:05 -04:00
|
|
|
value=f"Resolved by `{resolved_user.name}` ({resolved_user.id}) for:\n{box(moderation.resolve_reason)}",
|
2024-02-02 11:21:56 -05:00
|
|
|
inline=False,
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-04 17:48:08 -04:00
|
|
|
async def changes_factory(interaction: Interaction, moderation: Moderation) -> Embed:
|
2024-01-08 04:18:54 -05:00
|
|
|
"""This function creates a changes embed from set parameters.
|
|
|
|
|
|
|
|
Args:
|
2024-05-04 17:48:08 -04:00
|
|
|
interaction (discord.Interaction): The interaction object.
|
|
|
|
moderation (aurora.models.Moderation): The moderation object.
|
2024-01-08 04:18:54 -05:00
|
|
|
"""
|
2024-02-02 11:21:56 -05:00
|
|
|
embed = Embed(
|
2024-05-04 17:48:08 -04:00
|
|
|
title=f"📕 Case #{moderation.id:,} Changes",
|
2024-02-02 11:21:56 -05:00
|
|
|
color=await interaction.client.get_embed_color(interaction.channel),
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
memory_dict = {}
|
|
|
|
|
2024-05-04 17:48:08 -04:00
|
|
|
if moderation.changes:
|
|
|
|
for change in moderation.changes:
|
2024-05-04 21:15:39 -04:00
|
|
|
if change.user_id not in memory_dict:
|
|
|
|
memory_dict[str(change.user_id)] = await change.get_user()
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 21:19:06 -04:00
|
|
|
user: PartialUser = memory_dict[str(change.user_id)]
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 21:15:39 -04:00
|
|
|
timestamp = f"<t:{change.unix_timestamp}> | <t:{change.unix_timestamp}:R>"
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 21:15:39 -04:00
|
|
|
if change.type == "ORIGINAL":
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.add_field(
|
|
|
|
name="Original",
|
2024-05-04 21:19:06 -04:00
|
|
|
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}",
|
2024-02-02 11:21:56 -05:00
|
|
|
inline=False,
|
|
|
|
)
|
|
|
|
|
2024-05-04 21:15:39 -04:00
|
|
|
elif change.type == "EDIT":
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.add_field(
|
|
|
|
name="Edit",
|
2024-05-04 21:19:06 -04:00
|
|
|
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}",
|
2024-02-02 11:21:56 -05:00
|
|
|
inline=False,
|
|
|
|
)
|
|
|
|
|
2024-05-04 21:15:39 -04:00
|
|
|
elif change.type == "RESOLVE":
|
2024-02-02 11:21:56 -05:00
|
|
|
embed.add_field(
|
|
|
|
name="Resolve",
|
2024-05-04 21:19:06 -04:00
|
|
|
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}",
|
2024-02-02 11:21:56 -05:00
|
|
|
inline=False,
|
|
|
|
)
|
2024-01-08 04:18:54 -05:00
|
|
|
|
|
|
|
else:
|
|
|
|
embed.description = "*No changes have been made to this case.* 🙁"
|
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-05-06 16:47:21 -04:00
|
|
|
async def evidenceformat_factory(moderation: Moderation) -> str:
|
2024-01-08 04:18:54 -05:00
|
|
|
"""This function creates a codeblock in evidence format from set parameters.
|
|
|
|
|
|
|
|
Args:
|
2024-05-04 21:24:37 -04:00
|
|
|
interaction (discord.Interaction): The interaction object.
|
|
|
|
moderation (aurora.models.Moderation): The moderation object.
|
2024-01-08 04:18:54 -05:00
|
|
|
"""
|
2024-05-04 21:24:37 -04:00
|
|
|
target = await moderation.get_target()
|
|
|
|
moderator = await moderation.get_moderator()
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 21:24:37 -04:00
|
|
|
content = f"Case: {moderation.id:,} ({str.title(moderation.type)})\nTarget: {target.name} ({target.id})\nModerator: {moderator.name} ({moderator.id})"
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-04 21:24:37 -04:00
|
|
|
if moderation.duration is not None:
|
|
|
|
content += f"\nDuration: {humanize_timedelta(timedelta=moderation.duration)}"
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-06-04 11:48:15 -04:00
|
|
|
if moderation.role_id:
|
|
|
|
role = await moderation.get_role()
|
|
|
|
content += "\nRole: " + (role.name if role is not None else moderation.role_id)
|
2024-05-20 20:59:01 -04:00
|
|
|
|
2024-05-04 21:24:37 -04:00
|
|
|
content += f"\nReason: {moderation.reason}"
|
2024-01-08 04:18:54 -05:00
|
|
|
|
2024-05-24 04:22:42 -04:00
|
|
|
for key, value in moderation.metadata.items():
|
|
|
|
content += f"\n{key.title()}: {value}"
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
return box(content, "prolog")
|
2024-01-16 09:23:45 -05:00
|
|
|
|
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
### Configuration Embeds #
|
|
|
|
########################################################################################################################
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
async def _config(ctx: commands.Context) -> Embed:
|
2024-01-16 09:23:45 -05:00
|
|
|
"""Generates the core embed for configuration menus to use."""
|
2024-02-02 11:21:56 -05:00
|
|
|
e = Embed(title="Aurora Configuration Menu", color=await ctx.embed_color())
|
2024-01-16 09:23:45 -05:00
|
|
|
e.set_thumbnail(url=ctx.bot.user.display_avatar.url)
|
|
|
|
return e
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
async def overrides_embed(ctx: commands.Context) -> Embed:
|
2024-01-16 09:23:45 -05:00
|
|
|
"""Generates a configuration menu embed for a user's overrides."""
|
|
|
|
|
|
|
|
override_settings = {
|
|
|
|
"ephemeral": await config.user(ctx.author).history_ephemeral(),
|
|
|
|
"inline": await config.user(ctx.author).history_inline(),
|
|
|
|
"inline_pagesize": await config.user(ctx.author).history_inline_pagesize(),
|
|
|
|
"pagesize": await config.user(ctx.author).history_pagesize(),
|
2024-02-02 11:21:56 -05:00
|
|
|
"auto_evidenceformat": await config.user(ctx.author).auto_evidenceformat(),
|
2024-01-16 09:23:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
override_str = [
|
2024-02-02 11:21:56 -05:00
|
|
|
"- "
|
|
|
|
+ bold("Auto Evidence Format: ")
|
|
|
|
+ get_bool_emoji(override_settings["auto_evidenceformat"]),
|
|
|
|
"- " + bold("Ephemeral: ") + get_bool_emoji(override_settings["ephemeral"]),
|
|
|
|
"- " + bold("History Inline: ") + get_bool_emoji(override_settings["inline"]),
|
|
|
|
"- "
|
|
|
|
+ bold("History Inline Pagesize: ")
|
|
|
|
+ get_pagesize_str(override_settings["inline_pagesize"]),
|
|
|
|
"- "
|
|
|
|
+ bold("History Pagesize: ")
|
|
|
|
+ get_pagesize_str(override_settings["pagesize"]),
|
2024-01-16 09:23:45 -05:00
|
|
|
]
|
2024-02-02 11:21:56 -05:00
|
|
|
override_str = "\n".join(override_str)
|
2024-01-16 09:23:45 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
e = await _config(ctx)
|
2024-01-16 09:23:45 -05:00
|
|
|
e.title += ": User Overrides"
|
2024-02-02 11:21:56 -05:00
|
|
|
e.description = (
|
|
|
|
"""
|
2024-01-16 09:23:45 -05:00
|
|
|
Use the buttons below to manage your user overrides.
|
|
|
|
These settings will override the relevant guild settings.\n
|
2024-02-02 11:21:56 -05:00
|
|
|
"""
|
|
|
|
+ override_str
|
|
|
|
)
|
2024-01-16 09:23:45 -05:00
|
|
|
return e
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
async def guild_embed(ctx: commands.Context) -> Embed:
|
2024-01-16 09:23:45 -05:00
|
|
|
"""Generates a configuration menu field value for a guild's settings."""
|
|
|
|
|
|
|
|
guild_settings = {
|
|
|
|
"show_moderator": await config.guild(ctx.guild).show_moderator(),
|
2024-02-02 11:21:56 -05:00
|
|
|
"use_discord_permissions": await config.guild(
|
|
|
|
ctx.guild
|
|
|
|
).use_discord_permissions(),
|
2024-01-16 09:23:45 -05:00
|
|
|
"ignore_modlog": await config.guild(ctx.guild).ignore_modlog(),
|
|
|
|
"ignore_other_bots": await config.guild(ctx.guild).ignore_other_bots(),
|
|
|
|
"dm_users": await config.guild(ctx.guild).dm_users(),
|
|
|
|
"log_channel": await config.guild(ctx.guild).log_channel(),
|
|
|
|
"history_ephemeral": await config.guild(ctx.guild).history_ephemeral(),
|
|
|
|
"history_inline": await config.guild(ctx.guild).history_inline(),
|
|
|
|
"history_pagesize": await config.guild(ctx.guild).history_pagesize(),
|
2024-02-02 11:21:56 -05:00
|
|
|
"history_inline_pagesize": await config.guild(
|
|
|
|
ctx.guild
|
|
|
|
).history_inline_pagesize(),
|
2024-01-16 09:23:45 -05:00
|
|
|
"auto_evidenceformat": await config.guild(ctx.guild).auto_evidenceformat(),
|
2024-04-05 10:43:58 -04:00
|
|
|
"respect_hierarchy": await config.guild(ctx.guild).respect_hierarchy(),
|
2024-01-16 09:23:45 -05:00
|
|
|
}
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
channel = ctx.guild.get_channel(guild_settings["log_channel"])
|
2024-01-16 09:23:45 -05:00
|
|
|
if channel is None:
|
|
|
|
channel = warning("Not Set")
|
|
|
|
else:
|
|
|
|
channel = channel.mention
|
|
|
|
|
|
|
|
guild_str = [
|
2024-02-02 11:21:56 -05:00
|
|
|
"- "
|
|
|
|
+ bold("Show Moderator: ")
|
|
|
|
+ get_bool_emoji(guild_settings["show_moderator"]),
|
|
|
|
"- "
|
|
|
|
+ bold("Use Discord Permissions: ")
|
|
|
|
+ get_bool_emoji(guild_settings["use_discord_permissions"]),
|
|
|
|
"- "
|
2024-04-05 10:43:58 -04:00
|
|
|
+ bold("Respect Hierarchy: ")
|
|
|
|
+ get_bool_emoji(guild_settings["respect_hierarchy"]),
|
|
|
|
"- "
|
2024-02-02 11:21:56 -05:00
|
|
|
+ bold("Ignore Modlog: ")
|
|
|
|
+ get_bool_emoji(guild_settings["ignore_modlog"]),
|
|
|
|
"- "
|
|
|
|
+ bold("Ignore Other Bots: ")
|
|
|
|
+ get_bool_emoji(guild_settings["ignore_other_bots"]),
|
|
|
|
"- " + bold("DM Users: ") + get_bool_emoji(guild_settings["dm_users"]),
|
|
|
|
"- "
|
|
|
|
+ bold("Auto Evidence Format: ")
|
|
|
|
+ get_bool_emoji(guild_settings["auto_evidenceformat"]),
|
|
|
|
"- "
|
|
|
|
+ bold("Ephemeral: ")
|
|
|
|
+ get_bool_emoji(guild_settings["history_ephemeral"]),
|
|
|
|
"- "
|
|
|
|
+ bold("History Inline: ")
|
|
|
|
+ get_bool_emoji(guild_settings["history_inline"]),
|
|
|
|
"- "
|
|
|
|
+ bold("History Pagesize: ")
|
|
|
|
+ get_pagesize_str(guild_settings["history_pagesize"]),
|
|
|
|
"- "
|
|
|
|
+ bold("History Inline Pagesize: ")
|
|
|
|
+ get_pagesize_str(guild_settings["history_inline_pagesize"]),
|
|
|
|
"- " + bold("Log Channel: ") + channel,
|
2024-01-16 09:23:45 -05:00
|
|
|
]
|
2024-02-02 11:21:56 -05:00
|
|
|
guild_str = "\n".join(guild_str)
|
2024-01-16 09:23:45 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
e = await _config(ctx)
|
2024-01-16 09:23:45 -05:00
|
|
|
e.title += ": Server Configuration"
|
2024-02-02 11:21:56 -05:00
|
|
|
e.description = (
|
|
|
|
"""
|
2024-01-16 09:23:45 -05:00
|
|
|
Use the buttons below to manage Aurora's server configuration.\n
|
2024-02-02 11:21:56 -05:00
|
|
|
"""
|
|
|
|
+ guild_str
|
|
|
|
)
|
2024-01-16 09:23:45 -05:00
|
|
|
return e
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
async def addrole_embed(ctx: commands.Context) -> Embed:
|
2024-01-16 09:23:45 -05:00
|
|
|
"""Generates a configuration menu field value for a guild's addrole whitelist."""
|
|
|
|
|
2024-04-08 11:57:28 -04:00
|
|
|
roles = []
|
|
|
|
async with config.guild(ctx.guild).addrole_whitelist() as whitelist:
|
|
|
|
for role in whitelist:
|
|
|
|
evalulated_role = ctx.guild.get_role(role) or error(f"`{role}` (Not Found)")
|
|
|
|
if isinstance(evalulated_role, Role):
|
|
|
|
roles.append({
|
|
|
|
"id": evalulated_role.id,
|
|
|
|
"mention": evalulated_role.mention,
|
|
|
|
"position": evalulated_role.position
|
|
|
|
})
|
|
|
|
else:
|
|
|
|
roles.append({
|
|
|
|
"id": role,
|
|
|
|
"mention": error(f"`{role}` (Not Found)"),
|
|
|
|
"position": 0
|
|
|
|
})
|
|
|
|
|
|
|
|
if roles:
|
|
|
|
roles = sorted(roles, key=lambda x: x["position"], reverse=True)
|
|
|
|
roles = [role["mention"] for role in roles]
|
|
|
|
whitelist_str = "\n".join(roles)
|
2024-01-16 09:23:45 -05:00
|
|
|
else:
|
2024-04-08 11:57:28 -04:00
|
|
|
whitelist_str = warning("No roles are on the addrole whitelist!")
|
2024-01-16 09:23:45 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
e = await _config(ctx)
|
2024-01-16 09:23:45 -05:00
|
|
|
e.title += ": Addrole Whitelist"
|
2024-02-02 11:21:56 -05:00
|
|
|
e.description = (
|
|
|
|
"Use the select menu below to manage this guild's addrole whitelist."
|
|
|
|
)
|
2024-01-16 09:23:45 -05:00
|
|
|
|
2024-04-08 11:57:28 -04:00
|
|
|
if len(whitelist_str) > 4000 and len(whitelist_str) < 5000:
|
|
|
|
lines = whitelist_str.split("\n")
|
2024-01-16 09:23:45 -05:00
|
|
|
chunks = []
|
|
|
|
chunk = ""
|
|
|
|
for line in lines:
|
|
|
|
if len(chunk) + len(line) > 1024:
|
|
|
|
chunks.append(chunk)
|
|
|
|
chunk = line
|
|
|
|
else:
|
2024-02-02 11:21:56 -05:00
|
|
|
chunk += "\n" + line if chunk else line
|
2024-01-16 09:23:45 -05:00
|
|
|
chunks.append(chunk)
|
|
|
|
|
|
|
|
for chunk in chunks:
|
|
|
|
e.add_field(name="", value=chunk)
|
|
|
|
else:
|
2024-04-08 11:57:28 -04:00
|
|
|
e.description += "\n\n" + whitelist_str
|
2024-01-16 09:23:45 -05:00
|
|
|
|
|
|
|
return e
|
|
|
|
|
2024-02-02 11:21:56 -05:00
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
async def immune_embed(ctx: commands.Context) -> Embed:
|
2024-04-08 11:57:28 -04:00
|
|
|
"""Generates a configuration menu embed for a guild's immune roles."""
|
|
|
|
|
|
|
|
roles = []
|
|
|
|
async with config.guild(ctx.guild).immune_roles() as immune_roles:
|
|
|
|
for role in immune_roles:
|
|
|
|
evalulated_role = ctx.guild.get_role(role) or error(f"`{role}` (Not Found)")
|
|
|
|
if isinstance(evalulated_role, Role):
|
|
|
|
roles.append({
|
|
|
|
"id": evalulated_role.id,
|
|
|
|
"mention": evalulated_role.mention,
|
|
|
|
"position": evalulated_role.position
|
|
|
|
})
|
|
|
|
else:
|
|
|
|
roles.append({
|
|
|
|
"id": role,
|
|
|
|
"mention": error(f"`{role}` (Not Found)"),
|
|
|
|
"position": 0
|
|
|
|
})
|
|
|
|
|
|
|
|
if roles:
|
|
|
|
roles = sorted(roles, key=lambda x: x["position"], reverse=True)
|
|
|
|
roles = [role["mention"] for role in roles]
|
|
|
|
immune_str = "\n".join(roles)
|
2024-01-16 09:23:45 -05:00
|
|
|
else:
|
|
|
|
immune_str = warning("No roles are set as immune roles!")
|
|
|
|
|
2024-01-16 09:26:54 -05:00
|
|
|
e = await _config(ctx)
|
2024-01-16 09:23:45 -05:00
|
|
|
e.title += ": Immune Roles"
|
|
|
|
e.description = "Use the select menu below to manage this guild's immune roles."
|
|
|
|
|
|
|
|
if len(immune_str) > 4000 and len(immune_str) < 5000:
|
2024-02-02 11:21:56 -05:00
|
|
|
lines = immune_str.split("\n")
|
2024-01-16 09:23:45 -05:00
|
|
|
chunks = []
|
|
|
|
chunk = ""
|
|
|
|
for line in lines:
|
|
|
|
if len(chunk) + len(line) > 1024:
|
|
|
|
chunks.append(chunk)
|
|
|
|
chunk = line
|
|
|
|
else:
|
2024-02-02 11:21:56 -05:00
|
|
|
chunk += "\n" + line if chunk else line
|
2024-01-16 09:23:45 -05:00
|
|
|
chunks.append(chunk)
|
|
|
|
|
|
|
|
for chunk in chunks:
|
|
|
|
e.add_field(name="", value=chunk)
|
|
|
|
else:
|
2024-02-02 11:21:56 -05:00
|
|
|
e.description += "\n\n" + immune_str
|
2024-01-16 09:23:45 -05:00
|
|
|
|
|
|
|
return e
|