modified: bot.py
This commit is contained in:
61
bot.py
61
bot.py
@@ -1991,7 +1991,7 @@ async def modhelp(ctx):
|
|||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="👮 Moderator Commands (Level 5+)",
|
name="👮 Moderator Commands (Level 5+)",
|
||||||
value=(
|
value=(
|
||||||
"`/warn <user> [reason] [message_id]` - Warn a user (with optional message reference)\n"
|
"`/warn <user> <reason> [message_id]` - Warn a user (with optional message reference)\n"
|
||||||
"`/mute <user> <duration> [reason]` - Mute a user temporarily\n"
|
"`/mute <user> <duration> [reason]` - Mute a user temporarily\n"
|
||||||
"`/unmute <user>` - Manually unmute a user\n"
|
"`/unmute <user>` - Manually unmute a user\n"
|
||||||
"`/modinfo [user]` - View comprehensive user information\n"
|
"`/modinfo [user]` - View comprehensive user information\n"
|
||||||
@@ -2052,7 +2052,6 @@ async def modhelp(ctx):
|
|||||||
"**Mute duration formats:**\n"
|
"**Mute duration formats:**\n"
|
||||||
"`10m` = 10 minutes, `1h` = 1 hour, `2d` = 2 days\n\n"
|
"`10m` = 10 minutes, `1h` = 1 hour, `2d` = 2 days\n\n"
|
||||||
"**Warning with message reference:**\n"
|
"**Warning with message reference:**\n"
|
||||||
"`/warn @user Inappropriate behavior | 1234567890123456789`\n"
|
|
||||||
"`/warn @user Bad language 1234567890123456789`\n"
|
"`/warn @user Bad language 1234567890123456789`\n"
|
||||||
"The message will be saved even if deleted later."
|
"The message will be saved even if deleted later."
|
||||||
),
|
),
|
||||||
@@ -2938,46 +2937,23 @@ async def restore_user_roles(user, guild):
|
|||||||
close_database_connection(connection)
|
close_database_connection(connection)
|
||||||
|
|
||||||
@client.hybrid_command()
|
@client.hybrid_command()
|
||||||
async def warn(ctx, user: discord.User, *, reason_and_message: str = "No reason provided"):
|
async def warn(ctx, user: discord.User, reason: str = "No reason provided", message_id: int = None):
|
||||||
"""Warns a user (Requires Permission Level 5 or higher)
|
"""Warns a user (Requires Permission Level 5 or higher)
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
/warn @user Inappropriate behavior
|
/warn @user "Inappropriate behavior"
|
||||||
/warn @user Spam messages | 1234567890123456789
|
/warn @user "Bad language" 1234567890123456789
|
||||||
/warn @user Bad behavior 1234567890123456789
|
|
||||||
|
|
||||||
Format: reason | message_id OR reason message_id (message_id optional)
|
Parameters:
|
||||||
|
- user: The user to warn
|
||||||
|
- reason: Reason for the warning
|
||||||
|
- message_id: Optional message ID to reference
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Parse reason and optional message ID - support multiple formats
|
# message_data will be populated if message_id is provided
|
||||||
reason = reason_and_message.strip()
|
|
||||||
message_id = None
|
|
||||||
message_data = None
|
message_data = None
|
||||||
|
|
||||||
# Method 1: Check for " | " separator
|
# Try to get message data if message ID was provided
|
||||||
if " | " in reason_and_message:
|
|
||||||
reason_parts = reason_and_message.split(" | ")
|
|
||||||
reason = reason_parts[0].strip()
|
|
||||||
if len(reason_parts) > 1:
|
|
||||||
try:
|
|
||||||
message_id = int(reason_parts[1].strip())
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Method 2: Check if last word is a valid message ID (18-19 digits)
|
|
||||||
words = reason_and_message.strip().split()
|
|
||||||
if len(words) > 1:
|
|
||||||
last_word = words[-1]
|
|
||||||
# Discord message IDs are 18-19 digits long
|
|
||||||
if last_word.isdigit() and 17 <= len(last_word) <= 20:
|
|
||||||
try:
|
|
||||||
message_id = int(last_word)
|
|
||||||
# Remove the message ID from reason
|
|
||||||
reason = " ".join(words[:-1]).strip()
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Try to get message data if message ID was found
|
|
||||||
if message_id:
|
if message_id:
|
||||||
# Try to get message data from current channel first
|
# Try to get message data from current channel first
|
||||||
message_data = await get_message_data(ctx.channel, message_id)
|
message_data = await get_message_data(ctx.channel, message_id)
|
||||||
@@ -2995,23 +2971,6 @@ async def warn(ctx, user: discord.User, *, reason_and_message: str = "No reason
|
|||||||
# Load moderator data
|
# Load moderator data
|
||||||
mod_data = await load_user_data(ctx.author.id, ctx.guild.id)
|
mod_data = await load_user_data(ctx.author.id, ctx.guild.id)
|
||||||
|
|
||||||
# Debug: Show parsed information (for testing)
|
|
||||||
debug_info = f"**Parsed Information:**\n"
|
|
||||||
debug_info += f"Reason: `{reason}`\n"
|
|
||||||
if message_id:
|
|
||||||
debug_info += f"Message ID: `{message_id}`\n"
|
|
||||||
debug_info += f"Message Found: {'✅' if message_data else '❌'}"
|
|
||||||
else:
|
|
||||||
debug_info += "No Message ID provided"
|
|
||||||
|
|
||||||
# Send debug info as ephemeral message
|
|
||||||
debug_embed = discord.Embed(
|
|
||||||
title="🔍 Debug Information",
|
|
||||||
description=debug_info,
|
|
||||||
color=0x3498db
|
|
||||||
)
|
|
||||||
await ctx.send(embed=debug_embed, ephemeral=True)
|
|
||||||
|
|
||||||
# Check moderation rights
|
# Check moderation rights
|
||||||
if not check_moderation_permission(mod_data["permission"]):
|
if not check_moderation_permission(mod_data["permission"]):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
Reference in New Issue
Block a user