diff --git a/commands/voice.py b/commands/voice.py index 852895b..2c92332 100644 --- a/commands/voice.py +++ b/commands/voice.py @@ -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)) ) diff --git a/utils.py b/utils.py index 3e9ca82..29096c5 100644 --- a/utils.py +++ b/utils.py @@ -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")