fix: manually load opus if not loaded already
This commit is contained in:
parent
b9e5f1899e
commit
eeca6ec5d9
@ -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))
|
||||
)
|
||||
|
15
utils.py
15
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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user