Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions src/events/message_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, bot):
self.bot = bot

async def _add_intro_reactions(self, message: discord.Message) -> None:
if getattr(message, 'reference', None) and getattr(message.reference, 'message_id', None):
return

for emoji in INTRO_REACTIONS:
try:
await message.add_reaction(emoji)
Expand Down Expand Up @@ -96,10 +99,10 @@ async def on_message(self, message):
# Auto-react in introductions channel
if getattr(message.channel, 'id', None) == INTRODUCTION_CHANNEL_ID:
await self._add_intro_reactions(message)

# Check for thanks mentions
await self.check_thanks_mention(message)

# NOTE: Don't call process_commands here - the bot already does this automatically
# Calling it here would cause duplicate responses for prefix commands

Expand All @@ -118,11 +121,11 @@ async def check_thanks_mention(self, message):
author_member = message.guild.get_member(message.author.id)
if not author_member:
return

# Only server owner and admins can award aura
is_owner = author_member.id == message.guild.owner_id
is_admin = author_member.guild_permissions.administrator

if not (is_owner or is_admin):
return

Expand Down Expand Up @@ -169,10 +172,10 @@ async def on_command_error(self, ctx, error):
# Don't handle errors that are already handled by command-specific handlers
if hasattr(ctx.command, 'on_error'):
return

if isinstance(error, commands.CommandNotFound):
return # Ignore command not found errors

# For slash commands, check if interaction was already responded to
if hasattr(ctx, 'interaction') and ctx.interaction and ctx.interaction.response.is_done():
try:
Expand All @@ -186,15 +189,15 @@ async def on_command_error(self, ctx, error):
except:
pass # If followup also fails, just ignore
return

if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(
title="❌ Missing Permissions",
description="You don't have permission to use this command!",
color=discord.Color.red()
)
await ctx.send(embed=embed, delete_after=10)

elif isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(
title="❌ Missing Argument",
Expand All @@ -203,36 +206,36 @@ async def on_command_error(self, ctx, error):
color=discord.Color.red()
)
await ctx.send(embed=embed, delete_after=15)

elif isinstance(error, commands.BadArgument):
embed = discord.Embed(
title="❌ Invalid Argument",
title="❌ Invalid Argument",
description="Invalid argument provided!\n"
f"Use `?help {ctx.command}` for usage information.",
color=discord.Color.red()
)
await ctx.send(embed=embed, delete_after=15)

elif isinstance(error, commands.CommandOnCooldown):
embed = discord.Embed(
title="⏰ Command on Cooldown",
description=f"This command is on cooldown. Try again in {error.retry_after:.1f} seconds.",
color=discord.Color.orange()
)
await ctx.send(embed=embed, delete_after=10)

elif isinstance(error, commands.MemberNotFound):
embed = discord.Embed(
title="❌ Member Not Found",
description="Could not find the specified member!",
color=discord.Color.red()
)
await ctx.send(embed=embed, delete_after=10)

else:
# Log unexpected errors
print(f"Unhandled error in command {ctx.command}: {error}")

embed = discord.Embed(
title="❌ An Error Occurred",
description="An unexpected error occurred while processing your command.\n"
Expand All @@ -243,7 +246,7 @@ async def on_command_error(self, ctx, error):
await ctx.send(embed=embed, delete_after=15)
except:
pass # If sending fails, just ignore

# AFK and XP systems removed per request.

async def setup(bot):
Expand Down