feat(shard): ✨ Add duration and reason arguments to p.ban.

This commit is contained in:
2025-03-18 13:24:22 -03:00
parent 57459699ea
commit 41b8bb8825
6 changed files with 62 additions and 12 deletions
@@ -0,0 +1,11 @@
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "ban" ADD "reason" TEXT;"""
async def downgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "ban" DROP COLUMN "reason";"""
+9
View File
@@ -146,11 +146,20 @@ class Ban(models.Model):
user_id = fields.BigIntField()
report = fields.ForeignKeyField("models.Report", null=True)
reason = fields.TextField(null=True, default=None)
created_at = fields.DatetimeField(auto_now_add=True)
expires_at = fields.DatetimeField(null=True)
created_by = fields.ForeignKeyField("models.User", related_name="created_bans")
expired_by = fields.ForeignKeyField("models.User", related_name="expired_bans", null=True)
@property
def is_expired(self) -> bool:
"""
Whether the ban is expired.
"""
return self.expires_at is not None and self.expires_at < datetime.now(timezone.utc)
class Meta:
"""
Meta information.