Create jarvis.utils.embeds for various embeds
This commit is contained in:
parent
526038c725
commit
51c3298b86
2 changed files with 31 additions and 86 deletions
|
@ -22,6 +22,8 @@ from jarvis_core.util import build_embed
|
|||
from jarvis_core.util.ansi import RESET, Fore, Format, fmt
|
||||
from pastypy import AsyncPaste as Paste
|
||||
|
||||
from jarvis.utils.embeds import warning_embed
|
||||
|
||||
DEFAULT_GUILD = 862402786116763668
|
||||
DEFAULT_ERROR_CHANNEL = 943395824560394250
|
||||
DEFAULT_SITE = "https://paste.zevs.me"
|
||||
|
@ -213,25 +215,7 @@ class Jarvis(Snake):
|
|||
user=message.author.id,
|
||||
)
|
||||
await w.commit()
|
||||
fields = [
|
||||
EmbedField(
|
||||
name="Reason",
|
||||
value="Sent an invite link",
|
||||
inline=False,
|
||||
)
|
||||
]
|
||||
embed = build_embed(
|
||||
title="Warning",
|
||||
description=f"{message.author.mention} has been warned",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(
|
||||
name=message.author.display_name,
|
||||
icon_url=message.author.display_avatar.url,
|
||||
)
|
||||
embed.set_footer(
|
||||
text=f"{message.author.user.username}#{message.author.discriminator} | {message.author.id}" # noqa: E501
|
||||
)
|
||||
embed = warning_embed(message.author, "Sent an invite link")
|
||||
await message.channel.send(embed=embed)
|
||||
|
||||
async def massmention(self, message: Message) -> None:
|
||||
|
@ -247,7 +231,7 @@ class Jarvis(Snake):
|
|||
massmention
|
||||
and massmention.value > 0 # noqa: W503
|
||||
and len(message._mention_ids + message._mention_roles) # noqa: W503
|
||||
- (1 if message.author in message._mention_ids else 0) # noqa: W503
|
||||
- (1 if message.author.id in message._mention_ids else 0) # noqa: W503
|
||||
> massmention.value # noqa: W503
|
||||
):
|
||||
w = Warning(
|
||||
|
@ -259,26 +243,14 @@ class Jarvis(Snake):
|
|||
user=message.author.id,
|
||||
)
|
||||
await w.commit()
|
||||
fields = [EmbedField(name="Reason", value="Mass Mention", inline=False)]
|
||||
embed = build_embed(
|
||||
title="Warning",
|
||||
description=f"{message.author.mention} has been warned",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(
|
||||
name=message.author.display_name,
|
||||
icon_url=message.author.display_avatar.url,
|
||||
)
|
||||
embed.set_footer(
|
||||
text=f"{message.author.user.username}#{message.author.discriminator} | {message.author.id}"
|
||||
)
|
||||
embed = warning_embed(message.author, "Mass Mention")
|
||||
await message.channel.send(embed=embed)
|
||||
|
||||
async def roleping(self, message: Message) -> None:
|
||||
"""Handle roleping events."""
|
||||
if await Roleping.collection.count_documents(q(guild=message.guild.id, active=True)) == 0:
|
||||
return
|
||||
rolepings = Roleping.find(q(guild=message.guild.id, active=True))
|
||||
rolepings = await Roleping.find(q(guild=message.guild.id, active=True)).to_list(None)
|
||||
|
||||
# Get all role IDs involved with message
|
||||
roles = []
|
||||
|
@ -305,7 +277,7 @@ class Jarvis(Snake):
|
|||
|
||||
# Check if user in a bypass list
|
||||
user_has_bypass = False
|
||||
async for roleping in rolepings:
|
||||
for roleping in rolepings:
|
||||
if message.author.id in roleping.bypass["users"]:
|
||||
user_has_bypass = True
|
||||
break
|
||||
|
@ -323,25 +295,7 @@ class Jarvis(Snake):
|
|||
user=message.author.id,
|
||||
)
|
||||
await w.commit()
|
||||
fields = [
|
||||
EmbedField(
|
||||
name="Reason",
|
||||
value="Pinged a blocked role/user with a blocked role",
|
||||
inline=False,
|
||||
)
|
||||
]
|
||||
embed = build_embed(
|
||||
title="Warning",
|
||||
description=f"{message.author.mention} has been warned",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(
|
||||
name=message.author.display_name,
|
||||
icon_url=message.author.display_avatar.url,
|
||||
)
|
||||
embed.set_footer(
|
||||
text=f"{message.author.user.username}#{message.author.discriminator} | {message.author.id}"
|
||||
)
|
||||
embed = warning_embed(message.author, "Pinged a blocked role/user with a blocked role")
|
||||
await message.channel.send(embed=embed)
|
||||
|
||||
async def phishing(self, message: Message) -> None:
|
||||
|
@ -357,22 +311,7 @@ class Jarvis(Snake):
|
|||
user=message.author.id,
|
||||
)
|
||||
await w.commit()
|
||||
fields = [
|
||||
EmbedField(name="Reason", value="Phishing URL", inline=False),
|
||||
EmbedField(name="Message ID", value=str(message.id)),
|
||||
]
|
||||
embed = build_embed(
|
||||
title="Warning",
|
||||
description=f"{message.author.mention} has been warned",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(
|
||||
name=message.author.display_name,
|
||||
icon_url=message.author.display_avatar.url,
|
||||
)
|
||||
embed.set_footer(
|
||||
text=f"{message.author.user.username}#{message.author.discriminator} | {message.author.id}"
|
||||
)
|
||||
embed = warning_embed(message.author, "Phishing URL")
|
||||
await message.channel.send(embed=embed)
|
||||
await message.delete()
|
||||
return True
|
||||
|
@ -400,22 +339,7 @@ class Jarvis(Snake):
|
|||
)
|
||||
await w.commit()
|
||||
reasons = ", ".join(item["not_safe_reasons"])
|
||||
fields = [
|
||||
EmbedField(name="Reason", value=f"Unsafe URL: {reasons}", inline=False),
|
||||
EmbedField(name="Message ID", valud=str(message.id)),
|
||||
]
|
||||
embed = build_embed(
|
||||
title="Warning",
|
||||
description=f"{message.author.mention} has been warned",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(
|
||||
name=message.author.display_name,
|
||||
icon_url=message.author.display_avatar.url,
|
||||
)
|
||||
embed.set_footer(
|
||||
text=f"{message.author.user.username}#{message.author.discriminator} | {message.author.id}"
|
||||
)
|
||||
embed = warning_embed(message.author, reasons)
|
||||
await message.channel.send(embed=embed)
|
||||
await message.delete()
|
||||
return True
|
||||
|
|
21
jarvis/utils/embeds.py
Normal file
21
jarvis/utils/embeds.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""JARVIS bot-specific embeds."""
|
||||
from dis_snek.models.discord.embed import Embed, EmbedField
|
||||
from dis_snek.models.discord.user import Member
|
||||
from jarvis_core.util 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
|
||||
)
|
||||
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