feat(bot): ⚰️ Remove appeals support.

This commit is contained in:
Nyeki.py
2024-10-19 21:42:18 -03:00
parent a7a1183a8e
commit d2f3355644
6 changed files with 14 additions and 99 deletions
-5
View File
@@ -39,9 +39,6 @@ class Payphone(commands.AutoShardedBot):
console. console.
""" """
# Import from inside the function to prevent circular import errors.
from payphone.cogs.mods import views as mod_views
await setup.init() await setup.init()
await redis.ping() await redis.ping()
@@ -50,8 +47,6 @@ class Payphone(commands.AutoShardedBot):
constants.CHANNELS_ONCALL_SET, constants.CHANNELS_SEARCH_QUEUE constants.CHANNELS_ONCALL_SET, constants.CHANNELS_SEARCH_QUEUE
) )
self.add_view(mod_views.BanNotificationView(self, models.Ban()))
print(f"Ready! Logged in as {self.user.display_name}.") print(f"Ready! Logged in as {self.user.display_name}.")
async def on_shard_ready(self, shard_id: int) -> None: async def on_shard_ready(self, shard_id: int) -> None:
-1
View File
@@ -73,7 +73,6 @@ class Mods(base.Cog):
await self.bot.get_or_fetch_user(user_id) await self.bot.get_or_fetch_user(user_id)
).send( ).send(
embed=embeds.BanNotificationEmbed(self.bot, row), embed=embeds.BanNotificationEmbed(self.bot, row),
view=views.BanNotificationView(self.bot, row),
) )
row.notification_message_id = notification_message.id row.notification_message_id = notification_message.id
+1 -42
View File
@@ -1,5 +1,3 @@
from datetime import datetime, timezone
import discord import discord
from discord import errors from discord import errors
@@ -11,44 +9,6 @@ from payphone.core import formatting
from payphone.cogs.mods import embeds, views from payphone.cogs.mods import embeds, views
class BanNotificationModal(discord.ui.Modal):
"""Modal sent to users to appeal their ban."""
def __init__(self, bot: bot.Payphone) -> None:
"""Initializes the modal."""
self.bot = bot
super().__init__(
discord.ui.InputText(
custom_id="ban-notification-appeal:appeal",
label="Appeal",
placeholder="",
max_length=500,
required=True,
style=discord.InputTextStyle.long,
),
title="Ban Appeal",
custom_id="ban-notification-appeal",
timeout=None,
)
@transactions.atomic()
async def callback(self, interaction: discord.Interaction):
ban = await models.Ban.get(notification_message_id=interaction.message.id)
await interaction.response.defer()
ban.appeal = self.children[0].value
ban.status = models.BanStatus.ON_REVIEW
await ban.save()
await interaction.message.edit(
embed=embeds.BanNotificationEmbed(self.bot, ban),
view=views.BanNotificationView(self.bot, ban),
)
class BanUserModal(discord.ui.Modal): class BanUserModal(discord.ui.Modal):
"""Modal sent to ban a user.""" """Modal sent to ban a user."""
@@ -107,8 +67,7 @@ class BanUserModal(discord.ui.Modal):
notification_message = await ( notification_message = await (
await self.bot.get_or_fetch_user(self.profile.user_id) await self.bot.get_or_fetch_user(self.profile.user_id)
).send( ).send(
embed=embeds.BanNotificationEmbed(self.bot, ban), embed=embeds.BanNotificationEmbed(self.bot, ban)
view=views.BanNotificationView(self.bot, ban),
) )
ban.notification_message_id = notification_message.id ban.notification_message_id = notification_message.id
-42
View File
@@ -10,48 +10,6 @@ from payphone.core import constants
from payphone.cogs.mods import modals, views, embeds from payphone.cogs.mods import modals, views, embeds
class BanNotificationView(discord.ui.View):
"""View sent with the ban notification embed.
This view contains a button that sends a modal to appeal the ban.
"""
def __init__(self, bot: bot.Payphone, ban: models.Ban) -> None:
"""Initializes the view.
Args:
bot (bot.Payphone): The bot.
ban (models.Ban): The ban to appeal.
"""
super().__init__(timeout=None)
self.bot = bot
if ban.status != models.BanStatus.VALID:
self.disable_all_items()
self.children[0].label = "Appealed"
self.add_item(
discord.ui.Button(
label=f"Status: {ban.status.name.replace("_", " ").lower().title()}",
disabled=True,
)
)
@discord.ui.button(
label="Appeal Ban",
custom_id="ban-notification:appeal-ban",
style=discord.ButtonStyle.blurple,
)
async def callback(
self, _button: discord.ui.Button, interaction: discord.Interaction
) -> None:
"""Sends the ban appeal modal."""
await interaction.response.send_modal(modals.BanNotificationModal(self.bot))
class ReportView(discord.ui.View): class ReportView(discord.ui.View):
"""The view sent together with the report embed.""" """The view sent together with the report embed."""
@@ -0,0 +1,13 @@
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "ban" DROP COLUMN "appeal";
ALTER TABLE "ban" DROP COLUMN "status";"""
async def downgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "ban" ADD "appeal" VARCHAR(500);
ALTER TABLE "ban" ADD "status" SMALLINT NOT NULL DEFAULT 0;"""
-9
View File
@@ -337,13 +337,6 @@ class Report(models.Model):
created_at: datetime = fields.DatetimeField(auto_now_add=True) created_at: datetime = fields.DatetimeField(auto_now_add=True)
class BanStatus(enum.IntEnum):
VALID = 0
ON_REVIEW = 1
APPEAL_ACCEPTED = 2
APPEAL_DECLINED = 3
class Ban(models.Model): class Ban(models.Model):
user_id: int = fields.BigIntField() user_id: int = fields.BigIntField()
report: fields.ForeignKeyNullableRelation["Report"] = fields.ForeignKeyField( report: fields.ForeignKeyNullableRelation["Report"] = fields.ForeignKeyField(
@@ -354,8 +347,6 @@ class Ban(models.Model):
) )
notification_message_id: int = fields.BigIntField(null=True, db_index=True) notification_message_id: int = fields.BigIntField(null=True, db_index=True)
reason: str = fields.CharField(max_length=500) reason: str = fields.CharField(max_length=500)
appeal: str | None = fields.CharField(max_length=500, null=True)
status: BanStatus = fields.IntEnumField(BanStatus, default=BanStatus.VALID)
banned_by: fields.ForeignKeyRelation["User"] = fields.ForeignKeyField( banned_by: fields.ForeignKeyRelation["User"] = fields.ForeignKeyField(
"models.User", related_name="bans_created", null=True "models.User", related_name="bans_created", null=True
) )