modified: app.py
This commit is contained in:
24
app.py
24
app.py
@@ -189,6 +189,8 @@ def is_owner():
|
||||
async def reload_bot(ctx):
|
||||
"""Reloads the bot and syncs slash commands (Owner only)"""
|
||||
try:
|
||||
print(f"🔄 Reload command started by {ctx.author} (ID: {ctx.author.id})")
|
||||
|
||||
# Send initial message
|
||||
embed = discord.Embed(
|
||||
title="🔄 Bot Reload",
|
||||
@@ -196,9 +198,12 @@ async def reload_bot(ctx):
|
||||
color=discord.Color.yellow()
|
||||
)
|
||||
message = await ctx.send(embed=embed)
|
||||
print("📤 Initial reload message sent")
|
||||
|
||||
# Sync slash commands
|
||||
print("🔄 Starting command sync...")
|
||||
synced = await bot.tree.sync()
|
||||
print(f"✅ Synced {len(synced)} commands successfully")
|
||||
|
||||
# Update embed with success
|
||||
embed = discord.Embed(
|
||||
@@ -211,11 +216,16 @@ async def reload_bot(ctx):
|
||||
embed.set_footer(text=f"Reloaded by {ctx.author}", icon_url=ctx.author.avatar.url if ctx.author.avatar else None)
|
||||
|
||||
await message.edit(embed=embed)
|
||||
print("✅ Reload completed successfully")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Reload failed with error: {type(e).__name__}: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
embed = discord.Embed(
|
||||
title="❌ Reload Failed",
|
||||
description=f"Error during reload: {str(e)}",
|
||||
description=f"**Error Type:** {type(e).__name__}\n**Error:** {str(e)[:1500]}",
|
||||
color=discord.Color.red()
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
@@ -541,8 +551,16 @@ async def on_command_error(ctx, error):
|
||||
elif isinstance(error, commands.BadArgument):
|
||||
await ctx.send("❌ Invalid argument!")
|
||||
else:
|
||||
print(f"Unknown error: {error}")
|
||||
await ctx.send("❌ An unknown error occurred!")
|
||||
# Log detailed error information
|
||||
print(f"❌ Unknown error in command '{ctx.command}': {type(error).__name__}: {error}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Send detailed error to user if owner
|
||||
if ctx.author.id == OWNER_ID:
|
||||
await ctx.send(f"❌ **Error Details (Owner only):**\n```python\n{type(error).__name__}: {str(error)[:1800]}\n```")
|
||||
else:
|
||||
await ctx.send("❌ An unknown error occurred!")
|
||||
|
||||
async def main():
|
||||
"""Main function to start the bot"""
|
||||
|
||||
Reference in New Issue
Block a user