0.3.9.3.a3
Added /clear_nick_reviews mod-command: clears out pending nickname reviews from datafile
This commit is contained in:
parent
c09f36162d
commit
f14e84b89c
2
bot.py
2
bot.py
@ -9,7 +9,7 @@ from modules.common.boot_notice import post_boot_notice
|
||||
|
||||
# Version consists of:
|
||||
# Major.Enhancement.Minor.Patch.Test (Test is alphanumeric; doesn’t trigger auto update)
|
||||
VERSION = "0.3.9.3.a2"
|
||||
VERSION = "0.3.9.3.a3"
|
||||
|
||||
# ---------- Env loading ----------
|
||||
|
||||
|
@ -8,7 +8,7 @@ import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
|
||||
from mod_perms import is_moderator_userid
|
||||
from mod_perms import is_moderator_userid, require_mod_interaction
|
||||
from modules.common.emoji_accept import is_accept
|
||||
from modules.common.settings import cfg # ENV-first config helper
|
||||
|
||||
@ -168,7 +168,7 @@ class NickNudgeCog(commands.Cog):
|
||||
|
||||
await self._modlog(guild, f"🔎 Nickname review opened for {member.mention} — {method} — {_ts_rel(now_ts)}.")
|
||||
|
||||
# ---------- DM nudge loop (unchanged) ----------
|
||||
# ---------- DM nudge loop ----------
|
||||
|
||||
async def _nudge_loop(self):
|
||||
await self.bot.wait_until_ready()
|
||||
@ -394,6 +394,48 @@ class NickNudgeCog(commands.Cog):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ---------- Mod command to clear pending reviews from datafile ----------
|
||||
|
||||
@app_commands.command(name="clear_nick_reviews", description="Delete all PENDING nickname review records for this server.")
|
||||
async def clear_nick_reviews(self, interaction: discord.Interaction):
|
||||
"""Moderator-only. Clears all 'pending' entries in data_manager['nick_reviews'] for this guild."""
|
||||
# Must be used in a guild
|
||||
if not interaction.guild:
|
||||
return await interaction.response.send_message("Use this in a server.", ephemeral=True)
|
||||
|
||||
# Moderator permission check (your existing gate)
|
||||
if not await require_mod_interaction(interaction):
|
||||
return # require_mod_interaction already responded
|
||||
|
||||
dm = self.bot.data_manager
|
||||
|
||||
# Count pending records for this guild
|
||||
pending = [
|
||||
r for r in dm.get('nick_reviews')
|
||||
if r.get('guild_id') == interaction.guild.id and r.get('status') == 'pending'
|
||||
]
|
||||
count = len(pending)
|
||||
|
||||
# Remove pending records
|
||||
if count:
|
||||
dm.remove(
|
||||
'nick_reviews',
|
||||
lambda r: r.get('guild_id') == interaction.guild.id and r.get('status') == 'pending'
|
||||
)
|
||||
|
||||
# Modlog + ephemeral confirmation
|
||||
try:
|
||||
await self._modlog(
|
||||
interaction.guild,
|
||||
f"🧹 {interaction.user.mention} cleared **{count}** pending nickname review(s)."
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"Cleared **{count}** pending nickname review{'s' if count != 1 else ''}.",
|
||||
ephemeral=True
|
||||
)
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(NickNudgeCog(bot))
|
||||
|
Loading…
Reference in New Issue
Block a user