Add testing mode to AI moderation cog
This commit is contained in:
parent
996ef0bd21
commit
e57dc63e80
@ -708,11 +708,29 @@ class AIModerationCog(commands.Cog):
|
||||
)
|
||||
return
|
||||
await set_guild_config(interaction.guild.id, "EVENT_MODE", enabled)
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"Event mode is now {'enabled' if enabled else 'disabled'}.",
|
||||
ephemeral=False,
|
||||
)
|
||||
|
||||
@config_subgroup.command(
|
||||
name="testing_mode",
|
||||
description="Enable or disable testing mode (no actions are taken).",
|
||||
)
|
||||
@app_commands.describe(enabled="Enable testing mode (true/false)")
|
||||
async def testing_mode(self, interaction: discord.Interaction, enabled: bool):
|
||||
if not interaction.user.guild_permissions.administrator:
|
||||
await interaction.response.send_message(
|
||||
"You must be an administrator to use this command.", ephemeral=False
|
||||
)
|
||||
return
|
||||
await set_guild_config(interaction.guild.id, "TESTING_MODE", enabled)
|
||||
await interaction.response.send_message(
|
||||
f"Testing mode is now {'enabled' if enabled else 'disabled'}.",
|
||||
ephemeral=False,
|
||||
)
|
||||
|
||||
@infractions_subgroup.command(
|
||||
name="view",
|
||||
description="View a user's AI moderation infraction history (mod/admin only).",
|
||||
@ -1689,6 +1707,51 @@ CRITICAL: Do NOT output anything other than the required JSON response.
|
||||
) # Using discord.utils.utcnow() which is still supported
|
||||
|
||||
action_taken_message = "" # To append to the notification
|
||||
testing_mode = get_guild_config(guild_id, "TESTING_MODE", False)
|
||||
if testing_mode:
|
||||
action_taken_message = (
|
||||
f"[TEST MODE] Would have taken action `{action}`. No changes made."
|
||||
)
|
||||
notification_embed.color = discord.Color.greyple()
|
||||
log_channel_id = get_guild_config(message.guild.id, "MOD_LOG_CHANNEL_ID")
|
||||
log_channel = (
|
||||
self.bot.get_channel(log_channel_id)
|
||||
if log_channel_id
|
||||
else message.channel
|
||||
)
|
||||
if action == "SUICIDAL":
|
||||
suicidal_role_id = get_guild_config(
|
||||
message.guild.id, "SUICIDAL_PING_ROLE_ID"
|
||||
)
|
||||
suicidal_role = (
|
||||
message.guild.get_role(suicidal_role_id)
|
||||
if suicidal_role_id
|
||||
else None
|
||||
)
|
||||
ping_target = (
|
||||
suicidal_role.mention
|
||||
if suicidal_role
|
||||
else f"Role ID {suicidal_role_id} (Suicidal Content)"
|
||||
)
|
||||
if not suicidal_role:
|
||||
print(f"ERROR: Suicidal ping role ID {suicidal_role_id} not found.")
|
||||
final_message = f"{ping_target}\n{action_taken_message}"
|
||||
else:
|
||||
suggestions_id = get_guild_config(
|
||||
message.guild.id, "SUGGESTIONS_CHANNEL_ID"
|
||||
)
|
||||
suggestion_note = (
|
||||
f"\nPlease review <#{suggestions_id}> for rule updates."
|
||||
if suggestions_id
|
||||
else ""
|
||||
)
|
||||
final_message = f"{mod_ping}\n{action_taken_message}{suggestion_note}"
|
||||
await log_channel.send(
|
||||
content=final_message,
|
||||
embed=notification_embed,
|
||||
view=self.QuickActionView(self, message.author),
|
||||
)
|
||||
return
|
||||
|
||||
# --- Perform Actions ---
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user