85 lines
3.2 KiB
Python
85 lines
3.2 KiB
Python
import discord
|
|
from discord.utils import find
|
|
|
|
from payphone import bot
|
|
from payphone.db import models
|
|
from payphone.core import constants, formatting
|
|
|
|
|
|
class BanNotificationEmbed(discord.Embed):
|
|
"""Notification embed sent to users when they get banned."""
|
|
|
|
def __init__(self, bot: bot.Payphone, ban: models.Ban) -> None:
|
|
"""Initializes the embed.
|
|
|
|
Args:
|
|
bot (bot.Payphone): The instance of the bot.
|
|
ban (models.Ban): The ban.
|
|
"""
|
|
|
|
super().__init__(
|
|
color=constants.EMBED_COLOR,
|
|
title="You've Been Banned from Payphone",
|
|
description="You have been banned from using Payphone.",
|
|
fields=[
|
|
discord.EmbedField(
|
|
name="Reason",
|
|
value=ban.reason if ban.reason else "*No reason.*",
|
|
),
|
|
discord.EmbedField(
|
|
name="Expires At",
|
|
value=(
|
|
f"<t:{int(ban.expires_at.timestamp())}:F> (<t:{int(ban.expires_at.timestamp())}:R>)"
|
|
if ban.expires_at
|
|
else "*Does not expire.*"
|
|
),
|
|
),
|
|
],
|
|
author=bot.embed_author,
|
|
footer=discord.EmbedFooter(
|
|
text="If the ban was automatically set, it may be removed after a moderator checks it."
|
|
),
|
|
thumbnail=bot.user.display_avatar.url,
|
|
)
|
|
|
|
|
|
class ReportEmbed(discord.Embed):
|
|
"""The report embed shown to moderators."""
|
|
|
|
def __init__(self, bot: bot.Payphone, report: models.Report) -> None:
|
|
"""Initializes the embed.
|
|
|
|
Args:
|
|
bot (bot.Payphone): The instance of the bot.
|
|
report (models.Report): The report.
|
|
"""
|
|
|
|
reported_by_profile: models.Profile = find(
|
|
lambda rs: rs.user_id == report.reported_by_id, report.call.call_rss
|
|
).profile
|
|
|
|
super().__init__(
|
|
color=constants.EMBED_COLOR,
|
|
title="Report",
|
|
description=f"{reported_by_profile.link} reported a call.",
|
|
fields=[
|
|
discord.EmbedField(name="Reason", value=report.reason),
|
|
discord.EmbedField(
|
|
name="Participants",
|
|
value=(
|
|
f"Channel 1: {", ".join(map(lambda rs: rs.profile.link, filter(lambda rs: rs.channel_id == report.call.call_rss[0].channel_id, report.call.call_rss)))}\n"
|
|
f"Channel 2: {", ".join(map(lambda rs: rs.profile.link, filter(lambda rs: rs.channel_id != report.call.call_rss[0].channel_id, report.call.call_rss)))}"
|
|
),
|
|
),
|
|
discord.EmbedField(
|
|
name="Duration",
|
|
value=f"{formatting.time_to_text(report.call.ended_at - report.call.started_at)}, from <t:{int(report.call.started_at.timestamp())}:F> to <t:{int(report.call.ended_at.timestamp())}:F>.",
|
|
),
|
|
],
|
|
author=bot.embed_author,
|
|
footer=discord.EmbedFooter(
|
|
text=f"Call ID: {report.call.id} | Report ID: {report.id}"
|
|
),
|
|
thumbnail=bot.user.display_avatar.url,
|
|
)
|