aaa
This commit is contained in:
parent
d856e4ccef
commit
9abcbf84af
16
gurt/cog.py
16
gurt/cog.py
@ -190,19 +190,9 @@ class GurtCog(commands.Cog, name="Gurt"): # Added explicit Cog name
|
||||
|
||||
print("GurtCog: Listeners added.")
|
||||
|
||||
# Sync commands with Discord
|
||||
try:
|
||||
print("GurtCog: Syncing commands with Discord...")
|
||||
synced = await self.bot.tree.sync()
|
||||
print(f"GurtCog: Synced {len(synced)} command(s)")
|
||||
|
||||
# List the synced commands
|
||||
gurt_commands = [cmd.name for cmd in self.bot.tree.get_commands() if cmd.name.startswith("gurt")]
|
||||
print(f"GurtCog: Available Gurt commands: {', '.join(gurt_commands)}")
|
||||
except Exception as e:
|
||||
print(f"GurtCog: Failed to sync commands: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
# We'll sync commands in the on_ready event instead of here
|
||||
# This ensures the bot's application_id is properly set before syncing
|
||||
print("GurtCog: Commands will be synced when the bot is ready.")
|
||||
|
||||
# Start background task
|
||||
if self.background_task is None or self.background_task.done():
|
||||
|
@ -5,7 +5,7 @@ import asyncio
|
||||
import time
|
||||
import re
|
||||
import os # Added for file handling in error case
|
||||
from typing import TYPE_CHECKING, Union, Dict, Any
|
||||
from typing import TYPE_CHECKING, Union, Dict, Any, Optional
|
||||
|
||||
# Relative imports
|
||||
# Assuming api, utils, analysis functions are defined and imported correctly later
|
||||
@ -26,6 +26,20 @@ async def on_ready_listener(cog: 'GurtCog'):
|
||||
print(f'Gurt Bot is ready! Logged in as {cog.bot.user.name} ({cog.bot.user.id})')
|
||||
print('------')
|
||||
|
||||
# Now that the bot is ready, we can sync commands with Discord
|
||||
try:
|
||||
print("GurtCog: Syncing commands with Discord...")
|
||||
synced = await cog.bot.tree.sync()
|
||||
print(f"GurtCog: Synced {len(synced)} command(s)")
|
||||
|
||||
# List the synced commands
|
||||
gurt_commands = [cmd.name for cmd in cog.bot.tree.get_commands() if cmd.name.startswith("gurt")]
|
||||
print(f"GurtCog: Available Gurt commands: {', '.join(gurt_commands)}")
|
||||
except Exception as e:
|
||||
print(f"GurtCog: Failed to sync commands: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
async def on_message_listener(cog: 'GurtCog', message: discord.Message):
|
||||
"""Listener function for on_message."""
|
||||
# Import necessary functions dynamically or ensure they are passed/accessible via cog
|
||||
|
Loading…
x
Reference in New Issue
Block a user