modified: bot.py
This commit is contained in:
32
bot.py
32
bot.py
@@ -2976,8 +2976,10 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
Parameters:
|
||||
- user: The user to warn
|
||||
- reason: Reason for the warning
|
||||
- message_id: Optional message ID to reference
|
||||
- context_range: Number of messages before/after to archive (default: 3, max: 25)
|
||||
- message_id: Optional message ID to reference (required for context_range)
|
||||
- context_range: Number of messages before/after to archive (only works with message_id)
|
||||
|
||||
Note: context_range parameter only works when message_id is also provided!
|
||||
"""
|
||||
# Check if it's a slash command and defer if needed
|
||||
is_slash_command = hasattr(ctx, 'interaction') and ctx.interaction
|
||||
@@ -3006,7 +3008,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
# Check if reason ends with potential message ID and/or context range
|
||||
reason_words = reason.split()
|
||||
parsed_message_id = message_id
|
||||
parsed_context_range = context_range
|
||||
parsed_context_range = 3 # Default context range, only used if message_id is provided
|
||||
|
||||
# Look for patterns like "reason 1234567890123456789" or "reason 1234567890123456789 15"
|
||||
if len(reason_words) >= 2:
|
||||
@@ -3025,6 +3027,14 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
# Update reason without the message ID and context range
|
||||
reason = " ".join(reason_words)
|
||||
|
||||
# Only use context_range parameter if message_id is also provided
|
||||
if parsed_message_id and message_id and context_range != 3:
|
||||
# If message_id was provided as parameter and context_range was also set, use it
|
||||
parsed_context_range = context_range
|
||||
elif not parsed_message_id:
|
||||
# If no message_id was found, reset context_range to default
|
||||
parsed_context_range = 3
|
||||
|
||||
# Validate and limit context range
|
||||
if parsed_context_range < 1:
|
||||
parsed_context_range = 1
|
||||
@@ -3810,8 +3820,8 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
- user: The user to mute
|
||||
- duration: Duration (10m, 1h, 2d)
|
||||
- reason: Reason for the mute (can include message ID and context range)
|
||||
- message_id: Optional message ID to reference
|
||||
- context_range: Number of context messages to archive (1-25, default: 3)
|
||||
- message_id: Optional message ID to reference (required for context_range)
|
||||
- context_range: Number of context messages to archive (only works with message_id)
|
||||
|
||||
Duration examples:
|
||||
- 10m = 10 minutes
|
||||
@@ -3820,6 +3830,8 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
|
||||
You can also specify message ID and context range in the reason:
|
||||
"Bad language 1407754702564884622 15" (15 messages before/after)
|
||||
|
||||
Note: context_range parameter only works when message_id is also provided!
|
||||
"""
|
||||
# Check if it's a slash command and defer if needed
|
||||
is_slash_command = hasattr(ctx, 'interaction') and ctx.interaction
|
||||
@@ -3845,7 +3857,7 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
# Parse message ID and context range from reason if they look valid
|
||||
original_reason = reason
|
||||
message_data = None
|
||||
parsed_context_range = context_range
|
||||
parsed_context_range = 3 # Default context range, only used if message_id is provided
|
||||
|
||||
# Check if reason contains potential message ID and context range
|
||||
reason_words = reason.split()
|
||||
@@ -3867,6 +3879,14 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
message_id = potential_msg_id
|
||||
reason = " ".join(reason_words[:-1]) # Remove message ID from reason
|
||||
|
||||
# Only use context_range parameter if message_id is also provided
|
||||
if message_id and context_range != 3:
|
||||
# If message_id was provided and context_range was also set, use it
|
||||
parsed_context_range = context_range
|
||||
elif not message_id:
|
||||
# If no message_id was found, reset context_range to default
|
||||
parsed_context_range = 3
|
||||
|
||||
# Validate and limit context range
|
||||
if parsed_context_range < 1:
|
||||
parsed_context_range = 1
|
||||
|
||||
Reference in New Issue
Block a user