Manual mods to try and match old code
This commit is contained in:
@@ -87,11 +87,12 @@ class VoiceCog(commands.Cog):
|
|||||||
print(f"Failed to connect to {channel.name} in guild {guild.name}. Error: {e}")
|
print(f"Failed to connect to {channel.name} in guild {guild.name}. Error: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# --- IMPORTANT: Validate voice_client_to_use BEFORE passing to NoiseGate ---
|
|
||||||
if not voice_client_to_use:
|
if not voice_client_to_use:
|
||||||
print(f"Failed to obtain a valid VoiceClient object for guild {guild.name}.")
|
print(f"Failed to obtain a valid VoiceClient object for guild {guild.name}.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
print("Selected voice client to use.")
|
||||||
|
|
||||||
if discord.opus.is_loaded():
|
if discord.opus.is_loaded():
|
||||||
# Create and start the NoiseGate audio stream for this server
|
# Create and start the NoiseGate audio stream for this server
|
||||||
# Ensure the correct voice client is passed
|
# Ensure the correct voice client is passed
|
||||||
@@ -188,6 +189,9 @@ class DiscordBotManager:
|
|||||||
|
|
||||||
@self.bot.event
|
@self.bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
if not load_opus():
|
||||||
|
print("Failed to load Opus library. Bot cannot start voice features.")
|
||||||
|
return
|
||||||
print(f'Bot fully ready: {self.bot.user}')
|
print(f'Bot fully ready: {self.bot.user}')
|
||||||
# Set initial presence when the bot is ready
|
# Set initial presence when the bot is ready
|
||||||
await self.set_presence("Broadcasting...", discord.Game)
|
await self.set_presence("Broadcasting...", discord.Game)
|
||||||
@@ -199,16 +203,12 @@ class DiscordBotManager:
|
|||||||
|
|
||||||
self.token = token
|
self.token = token
|
||||||
|
|
||||||
if not load_opus():
|
|
||||||
print("Failed to load Opus library. Bot cannot start voice features.")
|
|
||||||
return
|
|
||||||
|
|
||||||
await self._setup_bot()
|
await self._setup_bot()
|
||||||
|
|
||||||
print("Starting bot...")
|
print("Starting bot...")
|
||||||
try:
|
try:
|
||||||
# Run the bot in a separate task so we can control it
|
# Run the bot in a separate task so we can control it
|
||||||
self._bot_task = asyncio.create_task(self.bot.start(self.token))
|
self._bot_task = asyncio.create_task(self.bot.run(self.token))
|
||||||
# Wait for the bot to connect (optional, useful for ensuring it's ready)
|
# Wait for the bot to connect (optional, useful for ensuring it's ready)
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
print("Bot started and is ready.")
|
print("Bot started and is ready.")
|
||||||
|
|||||||
Reference in New Issue
Block a user