fix: manually load opus if not loaded already

This commit is contained in:
Ryan 2025-01-06 16:11:27 -05:00
parent b9e5f1899e
commit eeca6ec5d9
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
2 changed files with 24 additions and 3 deletions

View File

@ -438,9 +438,15 @@ def play_next(message, once=False, first=False):
message.guild.voice_client.stop()
if message.guild.id in players and players[message.guild.id].queue:
queued = players[message.guild.id].queue_pop()
message.guild.voice_client.play(
queued.player, after=lambda e: play_after_callback(e, message, once)
)
try:
message.guild.voice_client.play(
queued.player, after=lambda e: play_after_callback(e, message, once)
)
except disnake.opus.OpusNotLoaded:
utils.load_opus()
message.guild.voice_client.play(
queued.player, after=lambda e: play_after_callback(e, message, once)
)
client.loop.create_task(
utils.channel_send(message, queued.format(show_queuer=not first))
)

View File

@ -1,3 +1,5 @@
import os
import disnake
import constants
@ -98,3 +100,16 @@ def filter_secrets(text: str) -> str:
continue
text = text.replace(secret, f"<{secret_name}>")
return text
def load_opus():
print("opus wasn't automatically loaded! trying to load manually...")
for path in ["/usr/lib64/libopus.so.0", "/usr/lib/libopus.so.0"]:
if os.path.exists(path):
try:
disnake.opus.load_opus(path)
print(f"successfully loaded opus from {path}")
return
except Exception as e:
print(f"failed to load opus from {path}: {e}")
raise Exception("could not locate working opus library")