fix: manually load opus if not loaded already
This commit is contained in:
parent
b9e5f1899e
commit
eeca6ec5d9
@ -438,6 +438,12 @@ def play_next(message, once=False, first=False):
|
|||||||
message.guild.voice_client.stop()
|
message.guild.voice_client.stop()
|
||||||
if message.guild.id in players and players[message.guild.id].queue:
|
if message.guild.id in players and players[message.guild.id].queue:
|
||||||
queued = players[message.guild.id].queue_pop()
|
queued = players[message.guild.id].queue_pop()
|
||||||
|
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(
|
message.guild.voice_client.play(
|
||||||
queued.player, after=lambda e: play_after_callback(e, message, once)
|
queued.player, after=lambda e: play_after_callback(e, message, once)
|
||||||
)
|
)
|
||||||
|
15
utils.py
15
utils.py
@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
import constants
|
import constants
|
||||||
@ -98,3 +100,16 @@ def filter_secrets(text: str) -> str:
|
|||||||
continue
|
continue
|
||||||
text = text.replace(secret, f"<{secret_name}>")
|
text = text.replace(secret, f"<{secret_name}>")
|
||||||
return text
|
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