feat(bot): ✨ Add remaining reports counter to p.reports.
This commit is contained in:
@@ -9,7 +9,7 @@ import discord
|
|||||||
from discord import errors
|
from discord import errors
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from tortoise import transactions
|
from tortoise import transactions, functions
|
||||||
|
|
||||||
from payphone import bot
|
from payphone import bot
|
||||||
from payphone.db import models, utils
|
from payphone.db import models, utils
|
||||||
@@ -183,6 +183,7 @@ class Mods(base.Cog):
|
|||||||
.select_related("call")
|
.select_related("call")
|
||||||
.prefetch_related("call__call_rss", "call__call_rss__profile")
|
.prefetch_related("call__call_rss", "call__call_rss__profile")
|
||||||
)
|
)
|
||||||
|
total = await models.Report.filter(status=models.ReportStatus.ON_REVIEW).count()
|
||||||
|
|
||||||
if report is None:
|
if report is None:
|
||||||
await ctx.send("✅ You're up to date! No reports left to check.")
|
await ctx.send("✅ You're up to date! No reports left to check.")
|
||||||
@@ -190,7 +191,7 @@ class Mods(base.Cog):
|
|||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
embed=embeds.ReportEmbed(self.bot, report),
|
embed=embeds.ReportEmbed(self.bot, report),
|
||||||
view=views.ReportView(self.bot, report),
|
view=views.ReportView(self.bot, report, total),
|
||||||
)
|
)
|
||||||
|
|
||||||
@commands.command(aliases=["mod"])
|
@commands.command(aliases=["mod"])
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import discord
|
|||||||
from discord.ext import pages
|
from discord.ext import pages
|
||||||
from discord.utils import find
|
from discord.utils import find
|
||||||
|
|
||||||
from tortoise import transactions
|
from tortoise import transactions, functions
|
||||||
|
|
||||||
from payphone import bot
|
from payphone import bot
|
||||||
from payphone.db import models
|
from payphone.db import models
|
||||||
@@ -55,12 +55,15 @@ class BanNotificationView(discord.ui.View):
|
|||||||
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."""
|
||||||
|
|
||||||
def __init__(self, bot: bot.Payphone, report: models.Report) -> None:
|
def __init__(
|
||||||
|
self, bot: bot.Payphone, report: models.Report, remaining_reports: int
|
||||||
|
) -> None:
|
||||||
"""Initializes the view.
|
"""Initializes the view.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
bot (bot.Payphone): The bot.
|
bot (bot.Payphone): The bot.
|
||||||
report (models.Report): The report.
|
report (models.Report): The report.
|
||||||
|
remaining_reports (int): The amount of reports that need to be reviewed remaining.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super().__init__(timeout=300, disable_on_timeout=True)
|
super().__init__(timeout=300, disable_on_timeout=True)
|
||||||
@@ -96,6 +99,9 @@ class ReportView(discord.ui.View):
|
|||||||
actions.callback = actions_callback
|
actions.callback = actions_callback
|
||||||
|
|
||||||
self.add_item(actions)
|
self.add_item(actions)
|
||||||
|
self.add_item(
|
||||||
|
discord.ui.Button(label=f"Remaining: {remaining_reports}", disabled=True, row=2)
|
||||||
|
)
|
||||||
|
|
||||||
@discord.ui.button(label="Message Logs", style=discord.ButtonStyle.gray, row=2)
|
@discord.ui.button(label="Message Logs", style=discord.ButtonStyle.gray, row=2)
|
||||||
async def message_logs(
|
async def message_logs(
|
||||||
@@ -181,6 +187,7 @@ class ReportView(discord.ui.View):
|
|||||||
.select_related("call")
|
.select_related("call")
|
||||||
.prefetch_related("call__call_rss", "call__call_rss__profile")
|
.prefetch_related("call__call_rss", "call__call_rss__profile")
|
||||||
)
|
)
|
||||||
|
total = await models.Report.filter(status=models.ReportStatus.ON_REVIEW).count()
|
||||||
|
|
||||||
if report is None:
|
if report is None:
|
||||||
await interaction.response.edit_message(
|
await interaction.response.edit_message(
|
||||||
@@ -192,7 +199,7 @@ class ReportView(discord.ui.View):
|
|||||||
|
|
||||||
await interaction.response.edit_message(
|
await interaction.response.edit_message(
|
||||||
embed=embeds.ReportEmbed(self.bot, report),
|
embed=embeds.ReportEmbed(self.bot, report),
|
||||||
view=views.ReportView(self.bot, report),
|
view=views.ReportView(self.bot, report, total),
|
||||||
)
|
)
|
||||||
|
|
||||||
@discord.ui.button(label="Decline", style=discord.ButtonStyle.red, row=2)
|
@discord.ui.button(label="Decline", style=discord.ButtonStyle.red, row=2)
|
||||||
@@ -213,6 +220,7 @@ class ReportView(discord.ui.View):
|
|||||||
.select_related("call")
|
.select_related("call")
|
||||||
.prefetch_related("call__call_rss", "call__call_rss__profile")
|
.prefetch_related("call__call_rss", "call__call_rss__profile")
|
||||||
)
|
)
|
||||||
|
total = await models.Report.filter(status=models.ReportStatus.ON_REVIEW).count()
|
||||||
|
|
||||||
if report is None:
|
if report is None:
|
||||||
await interaction.response.edit_message(
|
await interaction.response.edit_message(
|
||||||
@@ -224,5 +232,5 @@ class ReportView(discord.ui.View):
|
|||||||
|
|
||||||
await interaction.response.edit_message(
|
await interaction.response.edit_message(
|
||||||
embed=embeds.ReportEmbed(self.bot, report),
|
embed=embeds.ReportEmbed(self.bot, report),
|
||||||
view=views.ReportView(self.bot, report),
|
view=views.ReportView(self.bot, report, total),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ class Users(base.Cog):
|
|||||||
users_map[user_map[0]].leaderboard_position = i + 1
|
users_map[user_map[0]].leaderboard_position = i + 1
|
||||||
users_map[user_map[0]].leaderboard_calls_count = user_map[1]
|
users_map[user_map[0]].leaderboard_calls_count = user_map[1]
|
||||||
|
|
||||||
await models.User.bulk_update(users_map.values(), ["leaderboard_position", "leaderboard_calls_count"], 500)
|
await models.User.bulk_update(
|
||||||
|
users_map.values(), ["leaderboard_position", "leaderboard_calls_count"], 500
|
||||||
|
)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@transactions.atomic()
|
@transactions.atomic()
|
||||||
|
|||||||
Reference in New Issue
Block a user