|
|
@ -1,8 +1,12 @@
|
|
|
|
"""Module to manage audio trivia sessions."""
|
|
|
|
"""Module to manage audio trivia sessions."""
|
|
|
|
import asyncio
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
import lavalink
|
|
|
|
import lavalink
|
|
|
|
from redbot.cogs.trivia import TriviaSession
|
|
|
|
from redbot.cogs.trivia import TriviaSession
|
|
|
|
|
|
|
|
from redbot.core.utils.chat_formatting import bold
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger("red.fox_v3.audiotrivia.audiosession")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AudioSession(TriviaSession):
|
|
|
|
class AudioSession(TriviaSession):
|
|
|
@ -36,8 +40,8 @@ class AudioSession(TriviaSession):
|
|
|
|
self.count += 1
|
|
|
|
self.count += 1
|
|
|
|
await self.player.stop()
|
|
|
|
await self.player.stop()
|
|
|
|
|
|
|
|
|
|
|
|
msg = "**Question number {}!**\n\nName this audio!".format(self.count)
|
|
|
|
msg = bold(f"Question number {self.count}!") + "\n\nName this audio!"
|
|
|
|
await self.ctx.send(msg)
|
|
|
|
await self.ctx.maybe_send_embed(msg)
|
|
|
|
# print("Audio question: {}".format(question))
|
|
|
|
# print("Audio question: {}".format(question))
|
|
|
|
|
|
|
|
|
|
|
|
# await self.ctx.invoke(self.audio.play(ctx=self.ctx, query=question))
|
|
|
|
# await self.ctx.invoke(self.audio.play(ctx=self.ctx, query=question))
|
|
|
@ -45,7 +49,12 @@ class AudioSession(TriviaSession):
|
|
|
|
|
|
|
|
|
|
|
|
# await self.ctx.invoke(self.player.play, query=question)
|
|
|
|
# await self.ctx.invoke(self.player.play, query=question)
|
|
|
|
query = question.strip("<>")
|
|
|
|
query = question.strip("<>")
|
|
|
|
tracks = await self.player.get_tracks(query)
|
|
|
|
load_result = await self.player.load_tracks(query)
|
|
|
|
|
|
|
|
if load_result.has_error:
|
|
|
|
|
|
|
|
await self.ctx.maybe_send_embed(f"Track has error, skipping. See logs for details")
|
|
|
|
|
|
|
|
log.info(f"Track has error: {load_result.exception_message}")
|
|
|
|
|
|
|
|
continue # Skip tracks with error
|
|
|
|
|
|
|
|
tracks = load_result.tracks
|
|
|
|
seconds = tracks[0].length / 1000
|
|
|
|
seconds = tracks[0].length / 1000
|
|
|
|
|
|
|
|
|
|
|
|
if self.settings["repeat"] and seconds < delay:
|
|
|
|
if self.settings["repeat"] and seconds < delay:
|
|
|
|