feat(bot): ✨ Notify the reporter when their report has been accepted.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import discord
|
||||
from discord import errors
|
||||
from discord.ext import pages
|
||||
from discord.utils import find
|
||||
|
||||
@@ -6,7 +7,7 @@ from tortoise import transactions
|
||||
|
||||
from payphone import bot
|
||||
from payphone.db import models
|
||||
from payphone.core import constants
|
||||
from payphone.core import constants, formatting as fmt
|
||||
from payphone.cogs.mods import modals, views, embeds
|
||||
|
||||
|
||||
@@ -139,7 +140,7 @@ class ReportView(discord.ui.View):
|
||||
report.status = models.ReportStatus.ACCEPTED
|
||||
await report.save()
|
||||
|
||||
report = (
|
||||
next_report = (
|
||||
await models.Report.filter(status=models.ReportStatus.ON_REVIEW)
|
||||
.order_by("id")
|
||||
.limit(1)
|
||||
@@ -149,7 +150,35 @@ class ReportView(discord.ui.View):
|
||||
)
|
||||
total = await models.Report.filter(status=models.ReportStatus.ON_REVIEW).count()
|
||||
|
||||
if report is None:
|
||||
banned_user_ids = (
|
||||
await models.Ban.filter(report=report)
|
||||
.distinct()
|
||||
.values_list("user_id", flat=True)
|
||||
)
|
||||
|
||||
if len(banned_user_ids) > 0:
|
||||
profiles = [rs.profile for rs in report.call.call_rss if rs.user_id in banned_user_ids]
|
||||
|
||||
try:
|
||||
await (await self.bot.get_or_fetch_user(report.reported_by_id)).send(
|
||||
f"🔔 Your report for call `{report.call_id}` helped us ban "
|
||||
+ fmt.text_join(
|
||||
[
|
||||
(
|
||||
f"`{p.name}`"
|
||||
if p.user_id != report.reported_by_id
|
||||
else "`you`"
|
||||
)
|
||||
for p in profiles
|
||||
]
|
||||
)
|
||||
+ ". Thank you for your report!"
|
||||
)
|
||||
|
||||
except errors.DiscordException:
|
||||
pass
|
||||
|
||||
if next_report is None:
|
||||
await interaction.response.edit_message(
|
||||
content="✅ No reports left, have this cookie 🍪 !!",
|
||||
embed=None,
|
||||
@@ -158,8 +187,8 @@ class ReportView(discord.ui.View):
|
||||
return
|
||||
|
||||
await interaction.response.edit_message(
|
||||
embed=embeds.ReportEmbed(self.bot, report),
|
||||
view=views.ReportView(self.bot, report, total),
|
||||
embed=embeds.ReportEmbed(self.bot, next_report),
|
||||
view=views.ReportView(self.bot, next_report, total),
|
||||
)
|
||||
|
||||
@discord.ui.button(label="Decline", style=discord.ButtonStyle.red, row=2)
|
||||
|
||||
Reference in New Issue
Block a user