diff --git a/main.py b/main.py index 47b5412..74d33c9 100644 --- a/main.py +++ b/main.py @@ -64,7 +64,6 @@ logging.getLogger("discord.utils").setLevel(logging.DEBUG if DEBUG else logging. logging.getLogger("discord.app_commands").setLevel(logging.DEBUG if DEBUG else logging.WARNING) logging.getLogger("discord.ext.commands").setLevel(logging.DEBUG if DEBUG else logging.WARNING) logging.getLogger("discord.errors").setLevel(logging.DEBUG if DEBUG else logging.WARNING) -logging.getLogger("discord.utils").setLevel(logging.DEBUG if DEBUG else logging.WARNING) logging.getLogger("discord.client").setLevel(logging.DEBUG if DEBUG else logging.WARNING) # ─── Logging Configuration ─────────────────────────────────────────────────── @@ -118,6 +117,28 @@ tree.add_command(AppCommand(name="upload-emoji", callback=upload_emoji, descript tree.add_command(AppCommand(name="list-emojis", callback=list_emojis, description="List all custom emojis in the guild.")) tree.add_command(AppCommand(name="delete-emoji", callback=delete_emoji, description="Delete a custom emoji.")) +# ─── Prefix Commands ───────────────────────────────────────────────────────── + +@bot.command(name="ping", description="Check bot latency.") +async def ping_command(ctx: commands.Context) -> None: + """Check the bot's latency.""" + latency = round(bot.latency * 1000) + await ctx.send(f"Pong! Latency: {latency}ms") + +@bot.command(name="info", description="Show bot information.") +async def info_command(ctx: commands.Context) -> None: + """Show bot information.""" + await ctx.send( + f"**{ctx.guild.name if ctx.guild else 'DM'}**\n" + f"Bot: `{bot.user.name}` (ID: {bot.user.id})\n" + f"Latency: `{bot.latency:.3f}s`" + ) + +@bot.command(name="hello", description="Say hello to someone.") +async def hello_command(ctx: commands.Context, name: str = "World") -> None: + """Say hello to someone.""" + await ctx.send(f"Hello, {name}!") + # ─── Event Handlers ────────────────────────────────────────────────────────── @bot.event @@ -143,6 +164,7 @@ async def on_ready() -> None: @bot.event async def on_command_error(ctx: commands.Context, error: commands.CommandError) -> None: """Global error handler for all commands.""" + logger.debug(f"Command error for {ctx.author.name} ({ctx.author.id}): {error}") if isinstance(error, commands.CommandNotFound): await ctx.send("Command not found. Type `!help` for a list of commands.") elif isinstance(error, commands.CheckFailure): @@ -151,6 +173,13 @@ async def on_command_error(ctx: commands.Context, error: commands.CommandError) await ctx.send("You don't have permission to use this command.") elif isinstance(error, commands.MissingRequiredArgument): await ctx.send(f"Missing argument: {error.param.name}.") + elif isinstance(error, commands.BadArgument): + await ctx.send(f"Bad argument: {error.argument}.") + elif isinstance(error, commands.CommandOnCooldown): + remaining = int(error.retry_after) + await ctx.send( + f"This command is on cooldown. Try again in {remaining} seconds." + ) else: await ctx.send(f"An error occurred: {error}")