This commit is contained in:
2025-03-31 11:39:55 -03:00
7 changed files with 68 additions and 5 deletions
+8 -1
View File
@@ -115,6 +115,9 @@ class Admin(base.Cog):
except discord.Forbidden:
pass
user: models.User = await models.User.get(id=user.id)
await user.set_cache(self.bot.redis)
@commands.command(aliases=["sup"])
@commands.is_owner()
async def supporter(
@@ -159,7 +162,11 @@ class Admin(base.Cog):
- Bot Moderator
"""
report = await models.Report.filter(resolved=False).select_related("reported_by").first()
report = (
await models.Report.filter(resolved=False)
.select_related("reported_by")
.first()
)
if report is None:
return await ctx.send("✅ No reports left, have this cookie 🍪 !!")
+9 -2
View File
@@ -79,7 +79,7 @@ class ReportView(discord.ui.View):
user = await models.User.get_cache_or_db(self.bot.redis, self.report.user_id)
if select.values[0] == "warn":
if select.values[0] == "warn" and user.warns_count < 3:
user.warns_count += 1
await user.save(force_update=True)
await user.set_cache(self.bot.redis)
@@ -104,6 +104,13 @@ class ReportView(discord.ui.View):
),
)
warn = models.Warn(
user_id=self.report.user_id,
report=self.report,
created_by_id=interaction.user.id,
)
await warn.save()
try:
await (await self.bot.get_or_fetch_user(self.report.user_id)).send(
embed=embed
@@ -156,7 +163,7 @@ class ReportView(discord.ui.View):
expires_at = None
if select.values[0] == "ban":
if select.values[0] in ["ban", "warn"]:
expiry_times = {
1: datetime.now(timezone.utc) + timedelta(days=1),
2: datetime.now(timezone.utc) + timedelta(days=7),
+18
View File
@@ -73,6 +73,15 @@ class Calls(base.Cog):
f"☎️ You're not on a call! Use `{ctx.clean_prefix}call` to start one."
)
call = await self.bot.call_handler.get_call_by_channel_id(ctx.channel.id)
participant = await call.get_participant(ctx.author.id)
if participant is None:
return await ctx.send(
"❌ You cannot skip a call you have not participated in."
)
channels = await self.bot.call_handler.skip(ctx.channel.id)
for channel in channels:
@@ -104,6 +113,15 @@ class Calls(base.Cog):
f"☎️ You're not on a call! Use `{ctx.clean_prefix}call` to start one."
)
call = await self.bot.call_handler.get_call_by_channel_id(ctx.channel.id)
participant = await call.get_participant(ctx.author.id)
if participant is None:
return await ctx.send(
"❌ You cannot hang up a call you have not participated in."
)
channels = await self.bot.call_handler.hangup(ctx.channel.id)
other_channel = channels[0] if channels[0] != ctx.channel.id else channels[1]
+3 -1
View File
@@ -2,6 +2,8 @@ from dataclasses import dataclass
import orjson
import discord
from payphone.db import models
from payphone.bot import Payphone
from payphone.core import masks
@@ -551,7 +553,7 @@ class CallHandler:
return
for webhook in await channel.webhooks():
if webhook.name == "Payphone" and webhook.token is not None:
if webhook.user == self.bot.user and webhook.token is not None:
await self.bot.redis.hset(
"calls:channels:webhooks", channel_id, webhook.url
)
@@ -0,0 +1,19 @@
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
CREATE TABLE IF NOT EXISTS "warn" (
"id" SERIAL NOT NULL PRIMARY KEY,
"user_id" BIGINT NOT NULL,
"reason" TEXT,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"created_by_id" BIGINT NOT NULL REFERENCES "user" ("id") ON DELETE CASCADE,
"report_id" BIGINT REFERENCES "report" ("id") ON DELETE CASCADE
);
COMMENT ON TABLE "warn" IS 'A warn.';"""
async def downgrade(db: BaseDBAsyncClient) -> str:
return """
DROP TABLE IF EXISTS "warn";"""
+10
View File
@@ -144,6 +144,16 @@ class User(models.Model):
)
class Warn(models.Model):
"""A warn."""
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)
created_by = fields.ForeignKeyField("models.User", related_name="created_warns")
class Ban(models.Model):
"""
A ban.
Generated
+1 -1
View File
@@ -414,7 +414,7 @@ wheels = [
[[package]]
name = "payphone"
version = "0.66.0"
version = "0.67.0"
source = { virtual = "." }
dependencies = [
{ name = "aerich" },