Move to static embeds in own package
This commit is contained in:
parent
4d17115c09
commit
cb6c517667
10 changed files with 266 additions and 150 deletions
|
@ -46,9 +46,9 @@ from nafftrack.client import StatsClient
|
||||||
from pastypy import AsyncPaste as Paste
|
from pastypy import AsyncPaste as Paste
|
||||||
|
|
||||||
from jarvis import const
|
from jarvis import const
|
||||||
|
from jarvis.embeds.admin import warning_embed
|
||||||
from jarvis.tracking import jarvis_info, malicious_tracker, warnings_tracker
|
from jarvis.tracking import jarvis_info, malicious_tracker, warnings_tracker
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.embeds import warning_embed
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from aioredis import Redis
|
from aioredis import Redis
|
||||||
|
@ -513,7 +513,7 @@ class Jarvis(StatsClient):
|
||||||
guild_id=message.guild.id, guild_name=message.guild.name
|
guild_id=message.guild.id, guild_name=message.guild.name
|
||||||
)
|
)
|
||||||
tracker.inc()
|
tracker.inc()
|
||||||
embed = warning_embed(message.author, "Sent an invite link")
|
embed = warning_embed(message.author, "Sent an invite link", admin=self.user)
|
||||||
try:
|
try:
|
||||||
await message.channel.send(embeds=embed)
|
await message.channel.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -552,7 +552,7 @@ class Jarvis(StatsClient):
|
||||||
guild_id=message.guild.id, guild_name=message.guild.name
|
guild_id=message.guild.id, guild_name=message.guild.name
|
||||||
)
|
)
|
||||||
tracker.inc()
|
tracker.inc()
|
||||||
embed = warning_embed(message.author, "Mass Mention")
|
embed = warning_embed(message.author, "Mass Mention", admin=self.user)
|
||||||
try:
|
try:
|
||||||
await message.channel.send(embeds=embed)
|
await message.channel.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -620,7 +620,9 @@ class Jarvis(StatsClient):
|
||||||
guild_id=message.guild.id, guild_name=message.guild.name
|
guild_id=message.guild.id, guild_name=message.guild.name
|
||||||
)
|
)
|
||||||
tracker.inc()
|
tracker.inc()
|
||||||
embed = warning_embed(message.author, "Pinged a blocked role/user with a blocked role")
|
embed = warning_embed(
|
||||||
|
message.author, "Pinged a blocked role/user with a blocked role", admin=self.user
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
await message.channel.send(embeds=embed)
|
await message.channel.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -647,7 +649,7 @@ class Jarvis(StatsClient):
|
||||||
guild_id=message.guild.id, guild_name=message.guild.name
|
guild_id=message.guild.id, guild_name=message.guild.name
|
||||||
)
|
)
|
||||||
tracker.inc()
|
tracker.inc()
|
||||||
embed = warning_embed(message.author, "Phishing URL")
|
embed = warning_embed(message.author, "Phishing URL", admin=self.user)
|
||||||
try:
|
try:
|
||||||
await message.channel.send(embeds=embed)
|
await message.channel.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -693,7 +695,7 @@ class Jarvis(StatsClient):
|
||||||
)
|
)
|
||||||
tracker.inc()
|
tracker.inc()
|
||||||
reasons = ", ".join(item["not_safe_reasons"])
|
reasons = ", ".join(item["not_safe_reasons"])
|
||||||
embed = warning_embed(message.author, reasons)
|
embed = warning_embed(message.author, reasons, admin=self.user)
|
||||||
try:
|
try:
|
||||||
await message.channel.send(embeds=embed)
|
await message.channel.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -18,6 +18,7 @@ from naff.models.naff.application_commands import (
|
||||||
from naff.models.naff.command import check
|
from naff.models.naff.command import check
|
||||||
|
|
||||||
from jarvis.branding import get_command_color
|
from jarvis.branding import get_command_color
|
||||||
|
from jarvis.embeds.admin import ban_embed, unban_embed
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.cogs import ModcaseCog
|
from jarvis.utils.cogs import ModcaseCog
|
||||||
from jarvis.utils.permissions import admin_or_permissions
|
from jarvis.utils.permissions import admin_or_permissions
|
||||||
|
@ -33,7 +34,6 @@ class BanCog(ModcaseCog):
|
||||||
user: User,
|
user: User,
|
||||||
duration: int,
|
duration: int,
|
||||||
active: bool,
|
active: bool,
|
||||||
fields: list,
|
|
||||||
mtype: str,
|
mtype: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Apply a Discord ban."""
|
"""Apply a Discord ban."""
|
||||||
|
@ -51,20 +51,15 @@ class BanCog(ModcaseCog):
|
||||||
)
|
)
|
||||||
await b.commit()
|
await b.commit()
|
||||||
|
|
||||||
embed = build_embed(
|
embed = ban_embed(
|
||||||
title="User Banned",
|
user=user,
|
||||||
description=f"Reason: {reason}",
|
admin=ctx.author,
|
||||||
fields=fields,
|
reason=reason,
|
||||||
color=get_command_color("ban"),
|
guild=ctx.guild,
|
||||||
|
duration=duration,
|
||||||
|
type=mtype,
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.set_author(
|
|
||||||
name=user.display_name,
|
|
||||||
icon_url=user.avatar.url,
|
|
||||||
)
|
|
||||||
embed.set_thumbnail(url=user.avatar.url)
|
|
||||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
|
||||||
|
|
||||||
await ctx.send(embeds=embed)
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
async def discord_apply_unban(self, ctx: InteractionContext, user: User, reason: str) -> None:
|
async def discord_apply_unban(self, ctx: InteractionContext, user: User, reason: str) -> None:
|
||||||
|
@ -80,18 +75,8 @@ class BanCog(ModcaseCog):
|
||||||
)
|
)
|
||||||
await u.commit()
|
await u.commit()
|
||||||
|
|
||||||
embed = build_embed(
|
embed = unban_embed(user=user, admin=ctx.author, reason=reason)
|
||||||
title="User Unbanned",
|
|
||||||
description=f"<@{user.id}> was unbanned",
|
|
||||||
fields=[EmbedField(name="Reason", value=reason)],
|
|
||||||
color=get_command_color("unban"),
|
|
||||||
)
|
|
||||||
embed.set_author(
|
|
||||||
name=user.username,
|
|
||||||
icon_url=user.avatar.url,
|
|
||||||
)
|
|
||||||
embed.set_thumbnail(url=user.avatar.url)
|
|
||||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
|
||||||
await ctx.send(embeds=embed)
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
@slash_command(name="ban", description="Ban a user")
|
@slash_command(name="ban", description="Ban a user")
|
||||||
|
@ -152,45 +137,36 @@ class BanCog(ModcaseCog):
|
||||||
if mtype == "temp":
|
if mtype == "temp":
|
||||||
user_message += f"\nDuration: {duration} hours"
|
user_message += f"\nDuration: {duration} hours"
|
||||||
|
|
||||||
fields = [EmbedField(name="Type", value=mtype)]
|
user_embed = ban_embed(
|
||||||
|
user=user,
|
||||||
if mtype == "temp":
|
admin=ctx.author,
|
||||||
fields.append(EmbedField(name="Duration", value=f"{duration} hour(s)"))
|
reason=reason,
|
||||||
|
type=mtype,
|
||||||
user_embed = build_embed(
|
guild=ctx.guild,
|
||||||
title=f"You have been banned from {ctx.guild.name}",
|
duration=duration,
|
||||||
description=f"Reason: {reason}",
|
dm=True,
|
||||||
fields=fields,
|
|
||||||
color=get_command_color("ban"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
user_embed.set_author(
|
|
||||||
name=ctx.author.username + "#" + ctx.author.discriminator,
|
|
||||||
icon_url=ctx.author.avatar,
|
|
||||||
)
|
|
||||||
user_embed.set_thumbnail(url=ctx.guild.icon.url)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await user.send(embed=user_embed)
|
await user.send(embed=user_embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
send_failed = True
|
self.logger.warn(f"Failed to send ban embed to {user.id}")
|
||||||
try:
|
try:
|
||||||
await ctx.guild.ban(user, reason=reason)
|
await ctx.guild.ban(user, reason=reason)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await ctx.send(f"Failed to ban user:\n```\n{e}\n```", ephemeral=True)
|
await ctx.send(f"Failed to ban user:\n```\n{e}\n```", ephemeral=True)
|
||||||
return
|
return
|
||||||
send_failed = False
|
|
||||||
if mtype == "soft":
|
if mtype == "soft":
|
||||||
await ctx.guild.unban(user, reason="Ban was softban")
|
await ctx.guild.unban(user, reason="Ban was softban")
|
||||||
|
|
||||||
fields.append(EmbedField(name="DM Sent?", value=str(not send_failed)))
|
|
||||||
if btype != "temp":
|
if btype != "temp":
|
||||||
duration = None
|
duration = None
|
||||||
active = True
|
active = True
|
||||||
if btype == "soft":
|
if btype == "soft":
|
||||||
active = False
|
active = False
|
||||||
|
|
||||||
await self.discord_apply_ban(ctx, reason, user, duration, active, fields, mtype)
|
await self.discord_apply_ban(ctx, reason, user, duration, active, mtype)
|
||||||
|
|
||||||
@slash_command(name="unban", description="Unban a user")
|
@slash_command(name="unban", description="Unban a user")
|
||||||
@slash_option(
|
@slash_option(
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""JARVIS KickCog."""
|
"""JARVIS KickCog."""
|
||||||
from jarvis_core.db.models import Kick
|
from jarvis_core.db.models import Kick
|
||||||
from naff import InteractionContext, Permissions
|
from naff import InteractionContext, Permissions
|
||||||
from naff.models.discord.embed import EmbedField
|
|
||||||
from naff.models.discord.user import User
|
from naff.models.discord.user import User
|
||||||
from naff.models.naff.application_commands import (
|
from naff.models.naff.application_commands import (
|
||||||
OptionTypes,
|
OptionTypes,
|
||||||
|
@ -10,8 +9,7 @@ from naff.models.naff.application_commands import (
|
||||||
)
|
)
|
||||||
from naff.models.naff.command import check
|
from naff.models.naff.command import check
|
||||||
|
|
||||||
from jarvis.branding import get_command_color
|
from jarvis.embeds.admin import kick_embed
|
||||||
from jarvis.utils import build_embed
|
|
||||||
from jarvis.utils.cogs import ModcaseCog
|
from jarvis.utils.cogs import ModcaseCog
|
||||||
from jarvis.utils.permissions import admin_or_permissions
|
from jarvis.utils.permissions import admin_or_permissions
|
||||||
|
|
||||||
|
@ -39,41 +37,19 @@ class KickCog(ModcaseCog):
|
||||||
await ctx.send("User must be in guild", ephemeral=True)
|
await ctx.send("User must be in guild", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
guild_name = ctx.guild.name
|
embed = kick_embed(user=user, admin=ctx.author, reason=reason, guild=ctx.guild, dm=True)
|
||||||
embed = build_embed(
|
|
||||||
title=f"You have been kicked from {guild_name}",
|
|
||||||
description=f"Reason: {reason}",
|
|
||||||
fields=[],
|
|
||||||
color=get_command_color("kick"),
|
|
||||||
)
|
|
||||||
|
|
||||||
embed.set_author(
|
|
||||||
name=ctx.author.username + "#" + ctx.author.discriminator,
|
|
||||||
icon_url=ctx.author.display_avatar.url,
|
|
||||||
)
|
|
||||||
embed.set_thumbnail(url=ctx.guild.icon.url)
|
|
||||||
|
|
||||||
send_failed = False
|
|
||||||
try:
|
try:
|
||||||
await user.send(embeds=embed)
|
await user.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
send_failed = True
|
self.logger.warn(f"Failed to send kick message to {user.id}")
|
||||||
try:
|
try:
|
||||||
await ctx.guild.kick(user, reason=reason)
|
await ctx.guild.kick(user, reason=reason)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await ctx.send(f"Failed to kick user:\n```\n{e}\n```", ephemeral=True)
|
await ctx.send(f"Failed to kick user:\n```\n{e}\n```", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
fields = [EmbedField(name="DM Sent?", value=str(not send_failed))]
|
embed = kick_embed(user=user, admin=ctx.author, reason=reason, guild=ctx.guild)
|
||||||
embed = build_embed(
|
|
||||||
title="User Kicked",
|
|
||||||
description=f"Reason: {reason}",
|
|
||||||
fields=fields,
|
|
||||||
)
|
|
||||||
|
|
||||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
|
||||||
embed.set_thumbnail(url=user.display_avatar.url)
|
|
||||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
|
||||||
|
|
||||||
k = Kick(
|
k = Kick(
|
||||||
user=user.id,
|
user=user.id,
|
||||||
|
|
|
@ -7,7 +7,6 @@ from dateparser_data.settings import default_parsers
|
||||||
from jarvis_core.db.models import Mute
|
from jarvis_core.db.models import Mute
|
||||||
from naff import InteractionContext, Permissions
|
from naff import InteractionContext, Permissions
|
||||||
from naff.client.errors import Forbidden
|
from naff.client.errors import Forbidden
|
||||||
from naff.models.discord.embed import EmbedField
|
|
||||||
from naff.models.discord.modal import InputText, Modal, TextStyles
|
from naff.models.discord.modal import InputText, Modal, TextStyles
|
||||||
from naff.models.discord.user import Member
|
from naff.models.discord.user import Member
|
||||||
from naff.models.naff.application_commands import (
|
from naff.models.naff.application_commands import (
|
||||||
|
@ -20,8 +19,7 @@ from naff.models.naff.application_commands import (
|
||||||
)
|
)
|
||||||
from naff.models.naff.command import check
|
from naff.models.naff.command import check
|
||||||
|
|
||||||
from jarvis.branding import get_command_color
|
from jarvis.embeds.admin import mute_embed, unmute_embed
|
||||||
from jarvis.utils import build_embed
|
|
||||||
from jarvis.utils.cogs import ModcaseCog
|
from jarvis.utils.cogs import ModcaseCog
|
||||||
from jarvis.utils.permissions import admin_or_permissions
|
from jarvis.utils.permissions import admin_or_permissions
|
||||||
|
|
||||||
|
@ -42,21 +40,8 @@ class MuteCog(ModcaseCog):
|
||||||
duration=duration,
|
duration=duration,
|
||||||
active=True,
|
active=True,
|
||||||
).commit()
|
).commit()
|
||||||
ts = int(until.timestamp())
|
|
||||||
|
|
||||||
embed = build_embed(
|
return mute_embed(user=user, admin=ctx.author, reason=reason, guild=ctx.guild)
|
||||||
title="User Muted",
|
|
||||||
description=f"{user.mention} has been muted",
|
|
||||||
fields=[
|
|
||||||
EmbedField(name="Reason", value=reason),
|
|
||||||
EmbedField(name="Until", value=f"<t:{ts}:F> <t:{ts}:R>"),
|
|
||||||
],
|
|
||||||
color=get_command_color("mute"),
|
|
||||||
)
|
|
||||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
|
||||||
embed.set_thumbnail(url=user.display_avatar.url)
|
|
||||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@context_menu(name="Mute User", context_type=CommandTypes.USER)
|
@context_menu(name="Mute User", context_type=CommandTypes.USER)
|
||||||
@check(
|
@check(
|
||||||
|
@ -193,12 +178,15 @@ class MuteCog(ModcaseCog):
|
||||||
@slash_option(
|
@slash_option(
|
||||||
name="user", description="User to unmute", opt_type=OptionTypes.USER, required=True
|
name="user", description="User to unmute", opt_type=OptionTypes.USER, required=True
|
||||||
)
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="reason", description="Reason for unmute", opt_type=OptionTypes.STRING, required=True
|
||||||
|
)
|
||||||
@check(
|
@check(
|
||||||
admin_or_permissions(
|
admin_or_permissions(
|
||||||
Permissions.MUTE_MEMBERS, Permissions.BAN_MEMBERS, Permissions.KICK_MEMBERS
|
Permissions.MUTE_MEMBERS, Permissions.BAN_MEMBERS, Permissions.KICK_MEMBERS
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
async def _unmute(self, ctx: InteractionContext, user: Member) -> None:
|
async def _unmute(self, ctx: InteractionContext, user: Member, reason: str) -> None:
|
||||||
if (
|
if (
|
||||||
not user.communication_disabled_until
|
not user.communication_disabled_until
|
||||||
or user.communication_disabled_until.timestamp()
|
or user.communication_disabled_until.timestamp()
|
||||||
|
@ -209,13 +197,6 @@ class MuteCog(ModcaseCog):
|
||||||
|
|
||||||
await user.timeout(communication_disabled_until=datetime.now(tz=timezone.utc))
|
await user.timeout(communication_disabled_until=datetime.now(tz=timezone.utc))
|
||||||
|
|
||||||
embed = build_embed(
|
embed = unmute_embed(user=user, admin=ctx.author, reason=reason, guild=ctx.guild)
|
||||||
title="User Unmuted",
|
|
||||||
description=f"{user.mention} has been unmuted",
|
|
||||||
fields=[],
|
|
||||||
color=get_command_color("unmute"),
|
|
||||||
)
|
|
||||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
|
||||||
embed.set_thumbnail(url=user.display_avatar.url)
|
|
||||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
|
||||||
await ctx.send(embeds=embed)
|
await ctx.send(embeds=embed)
|
||||||
|
|
|
@ -15,9 +15,9 @@ from naff.models.naff.application_commands import (
|
||||||
)
|
)
|
||||||
from naff.models.naff.command import check
|
from naff.models.naff.command import check
|
||||||
|
|
||||||
|
from jarvis.embeds.admin import warning_embed
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.cogs import ModcaseCog
|
from jarvis.utils.cogs import ModcaseCog
|
||||||
from jarvis.utils.embeds import warning_embed
|
|
||||||
from jarvis.utils.permissions import admin_or_permissions
|
from jarvis.utils.permissions import admin_or_permissions
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class WarningCog(ModcaseCog):
|
||||||
expires_at=expires_at,
|
expires_at=expires_at,
|
||||||
active=True,
|
active=True,
|
||||||
).commit()
|
).commit()
|
||||||
embed = warning_embed(user, reason)
|
embed = warning_embed(user, reason, ctx.author)
|
||||||
await ctx.send(embeds=embed)
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
@slash_command(name="warnings", description="Get count of user warnings")
|
@slash_command(name="warnings", description="Get count of user warnings")
|
||||||
|
|
|
@ -16,11 +16,6 @@ from jarvis_core.db.models import (
|
||||||
SubredditFollow,
|
SubredditFollow,
|
||||||
UserSetting,
|
UserSetting,
|
||||||
)
|
)
|
||||||
|
|
||||||
from jarvis import const
|
|
||||||
from jarvis.config import JarvisConfig
|
|
||||||
from jarvis.utils import build_embed
|
|
||||||
from jarvis.utils.permissions import admin_or_permissions
|
|
||||||
from naff import Client, Extension, InteractionContext, Permissions
|
from naff import Client, Extension, InteractionContext, Permissions
|
||||||
from naff.client.utils.misc_utils import get
|
from naff.client.utils.misc_utils import get
|
||||||
from naff.models.discord.channel import ChannelTypes, GuildText
|
from naff.models.discord.channel import ChannelTypes, GuildText
|
||||||
|
@ -34,6 +29,11 @@ from naff.models.naff.application_commands import (
|
||||||
)
|
)
|
||||||
from naff.models.naff.command import check
|
from naff.models.naff.command import check
|
||||||
|
|
||||||
|
from jarvis import const
|
||||||
|
from jarvis.config import JarvisConfig
|
||||||
|
from jarvis.utils import build_embed
|
||||||
|
from jarvis.utils.permissions import admin_or_permissions
|
||||||
|
|
||||||
DEFAULT_USER_AGENT = f"python:JARVIS:{const.__version__} (by u/zevaryx)"
|
DEFAULT_USER_AGENT = f"python:JARVIS:{const.__version__} (by u/zevaryx)"
|
||||||
sub_name = re.compile(r"\A[A-Za-z0-9][A-Za-z0-9_]{2,20}\Z")
|
sub_name = re.compile(r"\A[A-Za-z0-9][A-Za-z0-9_]{2,20}\Z")
|
||||||
user_name = re.compile(r"[A-Za-z0-9_-]+")
|
user_name = re.compile(r"[A-Za-z0-9_-]+")
|
||||||
|
@ -116,7 +116,8 @@ class RedditCog(Extension):
|
||||||
)
|
)
|
||||||
base_embed.set_author(name="u/" + post.author.name, url=author_url, icon_url=author_icon)
|
base_embed.set_author(name="u/" + post.author.name, url=author_url, icon_url=author_icon)
|
||||||
base_embed.set_footer(
|
base_embed.set_footer(
|
||||||
text="Reddit", icon_url="https://www.redditinc.com/assets/images/site/reddit-logo.png"
|
text=f"r/{sub.display_name}",
|
||||||
|
icon_url="https://www.redditinc.com/assets/images/site/reddit-logo.png",
|
||||||
)
|
)
|
||||||
|
|
||||||
embeds = [base_embed]
|
embeds = [base_embed]
|
||||||
|
|
|
@ -153,7 +153,7 @@ class RemindmeCog(Extension):
|
||||||
EmbedField(name="Message", value=message),
|
EmbedField(name="Message", value=message),
|
||||||
EmbedField(
|
EmbedField(
|
||||||
name="When",
|
name="When",
|
||||||
value=f"<t:{int(remind_at.timestamp())}:F>",
|
value=f"<t:{int(remind_at.timestamp())}:F> (<t:{int(remind_at.timestamp())}:R>)",
|
||||||
inline=False,
|
inline=False,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -182,7 +182,7 @@ class RemindmeCog(Extension):
|
||||||
if reminder.private and isinstance(ctx.channel, GuildChannel):
|
if reminder.private and isinstance(ctx.channel, GuildChannel):
|
||||||
fields.embed(
|
fields.embed(
|
||||||
EmbedField(
|
EmbedField(
|
||||||
name=f"<t:{int(reminder.remind_at.timestamp())}:F>",
|
name=f"<t:{int(reminder.remind_at.timestamp())}:F> (<t:{int(reminder.remind_at.timestamp())}:R>)",
|
||||||
value="Please DM me this command to view the content of this reminder",
|
value="Please DM me this command to view the content of this reminder",
|
||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
|
@ -190,7 +190,7 @@ class RemindmeCog(Extension):
|
||||||
else:
|
else:
|
||||||
fields.append(
|
fields.append(
|
||||||
EmbedField(
|
EmbedField(
|
||||||
name=f"<t:{int(reminder.remind_at.timestamp())}:F>",
|
name=f"<t:{int(reminder.remind_at.timestamp())}:F> (<t:{int(reminder.remind_at.timestamp())}:R>)",
|
||||||
value=f"{reminder.message}\n\u200b",
|
value=f"{reminder.message}\n\u200b",
|
||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
|
@ -282,8 +282,12 @@ class RemindmeCog(Extension):
|
||||||
return
|
return
|
||||||
|
|
||||||
ts = int(reminder.remind_at.timestamp())
|
ts = int(reminder.remind_at.timestamp())
|
||||||
|
cts = int(reminder.created_at.timestamp())
|
||||||
|
|
||||||
fields = [EmbedField(name="Remind At", value=f"<t:{ts}:F> (<t:{ts}:R>)")]
|
fields = [
|
||||||
|
EmbedField(name="Remind At", value=f"<t:{ts}:F> (<t:{ts}:R>)"),
|
||||||
|
EmbedField(name="Created At", value=f"<t:{cts}:F> (<t:{cts}:R>)"),
|
||||||
|
]
|
||||||
|
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="You have a reminder!", description=reminder.message, fields=fields
|
title="You have a reminder!", description=reminder.message, fields=fields
|
||||||
|
|
|
@ -90,7 +90,6 @@ class RolegiverCog(Extension):
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.set_thumbnail(url=ctx.guild.icon.url)
|
embed.set_thumbnail(url=ctx.guild.icon.url)
|
||||||
embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.display_avatar.url)
|
|
||||||
|
|
||||||
embed.set_footer(text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}")
|
embed.set_footer(text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}")
|
||||||
components = Button(
|
components = Button(
|
||||||
|
@ -164,7 +163,6 @@ class RolegiverCog(Extension):
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.set_thumbnail(url=ctx.guild.icon.url)
|
embed.set_thumbnail(url=ctx.guild.icon.url)
|
||||||
embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.display_avatar.url)
|
|
||||||
|
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}"
|
text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}"
|
||||||
|
@ -207,10 +205,6 @@ class RolegiverCog(Extension):
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.set_thumbnail(url=ctx.guild.icon.url)
|
embed.set_thumbnail(url=ctx.guild.icon.url)
|
||||||
embed.set_author(
|
|
||||||
name=ctx.author.display_name,
|
|
||||||
icon_url=ctx.author.display_avatar.url,
|
|
||||||
)
|
|
||||||
|
|
||||||
embed.set_footer(text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}")
|
embed.set_footer(text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}")
|
||||||
components = Button(
|
components = Button(
|
||||||
|
|
208
jarvis/embeds/admin.py
Normal file
208
jarvis/embeds/admin.py
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
"""JARVIS bot-specific embeds."""
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from naff.models.discord.embed import Embed, EmbedField
|
||||||
|
from naff.models.discord.guild import Guild
|
||||||
|
from naff.models.discord.user import Member, User
|
||||||
|
|
||||||
|
from jarvis.branding import get_command_color
|
||||||
|
from jarvis.utils import build_embed
|
||||||
|
|
||||||
|
|
||||||
|
def ban_embed(
|
||||||
|
user: User,
|
||||||
|
admin: User,
|
||||||
|
reason: str,
|
||||||
|
type: str,
|
||||||
|
guild: Guild,
|
||||||
|
duration: Optional[int] = None,
|
||||||
|
dm: bool = False,
|
||||||
|
) -> Embed:
|
||||||
|
"""
|
||||||
|
Generate a ban embed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: User to ban
|
||||||
|
admin: Admin to execute ban
|
||||||
|
reason: Reason for ban
|
||||||
|
type: Ban type
|
||||||
|
guild: Guild to ban from
|
||||||
|
duration: Optional temporary ban duration
|
||||||
|
dm: If the embed should be a user embed
|
||||||
|
"""
|
||||||
|
fields = [EmbedField(name="Reason", value=reason), EmbedField(name="Type", value=type)]
|
||||||
|
if duration:
|
||||||
|
fields.append(EmbedField(name="Duration", value=f"{duration} hours"))
|
||||||
|
fields.append(
|
||||||
|
EmbedField(name="Admin", value=f"{admin.username}#{admin.discriminator} ({admin.mention})")
|
||||||
|
)
|
||||||
|
if dm:
|
||||||
|
embed = build_embed(
|
||||||
|
title=f"You have been banned from {guild.name}",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("ban"),
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=guild.icon.url)
|
||||||
|
else:
|
||||||
|
embed = build_embed(
|
||||||
|
title="User Banned",
|
||||||
|
description=f"{user.mention} has been banned",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("ban"),
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=user.display_avatar.url)
|
||||||
|
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
def unban_embed(user: User, admin: User, reason: str) -> Embed:
|
||||||
|
"""
|
||||||
|
Generate an unban embed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: User to unban
|
||||||
|
admin: Admin to execute unban
|
||||||
|
reason: Reason for unban
|
||||||
|
"""
|
||||||
|
fields = (
|
||||||
|
EmbedField(name="Reason", value=reason),
|
||||||
|
EmbedField(name="Admin", value=f"{admin.username}#{admin.discriminator} ({admin.mention})"),
|
||||||
|
)
|
||||||
|
embed = build_embed(
|
||||||
|
title="User Unbanned",
|
||||||
|
description=f"{user.mention} was unbanned",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("unban"),
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=user.display_avatar.url)
|
||||||
|
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
def kick_embed(user: Member, admin: Member, reason: str, guild: Guild, dm: bool = False) -> Embed:
|
||||||
|
"""
|
||||||
|
Generate a kick embed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: User to kick
|
||||||
|
admin: Admin to execute kick
|
||||||
|
reason: Reason for kick
|
||||||
|
guild: Guild to kick from
|
||||||
|
dm: If the embed should be a user embed
|
||||||
|
"""
|
||||||
|
fields = [
|
||||||
|
EmbedField(name="Reason", value="A valid reason"),
|
||||||
|
EmbedField(
|
||||||
|
name="Admin",
|
||||||
|
value=f"{admin.username}#{admin.discriminator} ({admin.mention})",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
if dm:
|
||||||
|
embed = build_embed(
|
||||||
|
title=f"You have been kicked from {guild.name}",
|
||||||
|
color=get_command_color("kick"),
|
||||||
|
fields=fields,
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=guild.icon.url)
|
||||||
|
else:
|
||||||
|
embed = build_embed(
|
||||||
|
title="User Kicked",
|
||||||
|
description=f"{user.mention} has been kicked",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("kick"),
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
def mute_embed(user: Member, admin: Member, reason: str, guild: Guild) -> Embed:
|
||||||
|
"""
|
||||||
|
Generate a mute embed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: User to mute
|
||||||
|
admin: Admin to execute mute
|
||||||
|
reason: Reason for mute
|
||||||
|
"""
|
||||||
|
until = int(user.communication_disabled_until.timestamp())
|
||||||
|
fields = (
|
||||||
|
EmbedField(name="Reason", value=reason),
|
||||||
|
EmbedField(name="Until", value=f"<t:{until}:F> (<t:{until}:R>)"),
|
||||||
|
EmbedField(
|
||||||
|
name="Admin",
|
||||||
|
value=f"{admin.username}#{admin.discriminator} ({admin.mention})",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
embed = build_embed(
|
||||||
|
title="User Muted",
|
||||||
|
description=f"{user.mention} has been muted",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("mute"),
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_thumbnail(url=user.display_avatar.url)
|
||||||
|
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
def unmute_embed(user: Member, admin: Member, reason: str, guild: Guild) -> Embed:
|
||||||
|
"""
|
||||||
|
Generate an umute embed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: User to unmute
|
||||||
|
admin: Admin to execute unmute
|
||||||
|
reason: Reason for unmute
|
||||||
|
"""
|
||||||
|
fields = (
|
||||||
|
EmbedField(name="Reason", value=reason),
|
||||||
|
EmbedField(
|
||||||
|
name="Admin",
|
||||||
|
value=f"{admin.username}#{admin.discriminator} ({admin.mention})",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
embed = build_embed(
|
||||||
|
title="User Unmuted",
|
||||||
|
description=f"{user.mention} has been unmuted",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("mute"),
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_thumbnail(url=user.display_avatar.url)
|
||||||
|
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
def warning_embed(user: Member, reason: str, admin: Member) -> Embed:
|
||||||
|
"""
|
||||||
|
Generate a warning embed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: User to warn
|
||||||
|
reason: Warning reason
|
||||||
|
admin: Admin who sent the warning
|
||||||
|
"""
|
||||||
|
fields = (
|
||||||
|
EmbedField(name="Reason", value=reason, inline=False),
|
||||||
|
EmbedField(name="Admin", value=f"{admin.username}#{admin.discriminator} ({admin.mention})"),
|
||||||
|
)
|
||||||
|
embed = build_embed(
|
||||||
|
title="Warning",
|
||||||
|
description=f"{user.mention} has been warned",
|
||||||
|
fields=fields,
|
||||||
|
color=get_command_color("warning"),
|
||||||
|
)
|
||||||
|
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||||
|
return embed
|
|
@ -1,26 +0,0 @@
|
||||||
"""JARVIS bot-specific embeds."""
|
|
||||||
from naff.models.discord.embed import Embed, EmbedField
|
|
||||||
from naff.models.discord.user import Member
|
|
||||||
|
|
||||||
from jarvis.branding import get_command_color
|
|
||||||
from jarvis.utils import build_embed
|
|
||||||
|
|
||||||
|
|
||||||
def warning_embed(user: Member, reason: str) -> Embed:
|
|
||||||
"""
|
|
||||||
Generate a warning embed.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
user: User to warn
|
|
||||||
reason: Warning reason
|
|
||||||
"""
|
|
||||||
fields = (EmbedField(name="Reason", value=reason, inline=False),)
|
|
||||||
embed = build_embed(
|
|
||||||
title="Warning",
|
|
||||||
description=f"{user.mention} has been warned",
|
|
||||||
fields=fields,
|
|
||||||
color=get_command_color("warning"),
|
|
||||||
)
|
|
||||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
|
||||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
|
||||||
return embed
|
|
Loading…
Add table
Reference in a new issue