From e0042780a1f9db38e29e42862da2972bd42a46fe Mon Sep 17 00:00:00 2001 From: bobloy Date: Wed, 23 Sep 2020 11:39:34 -0400 Subject: [PATCH 1/3] Better detection of bad questions in trivia --- audiotrivia/audiosession.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/audiotrivia/audiosession.py b/audiotrivia/audiosession.py index 4207fab..04d53c2 100644 --- a/audiotrivia/audiosession.py +++ b/audiotrivia/audiosession.py @@ -3,6 +3,7 @@ import asyncio import logging import lavalink +from lavalink.enums import LoadType from redbot.cogs.trivia import TriviaSession from redbot.core.utils.chat_formatting import bold @@ -42,6 +43,7 @@ class AudioSession(TriviaSession): msg = bold(f"Question number {self.count}!") + "\n\nName this audio!" await self.ctx.maybe_send_embed(msg) + log.debug(f"Audio question: {question}") # print("Audio question: {}".format(question)) # await self.ctx.invoke(self.audio.play(ctx=self.ctx, query=question)) @@ -50,7 +52,8 @@ class AudioSession(TriviaSession): # await self.ctx.invoke(self.player.play, query=question) query = question.strip("<>") load_result = await self.player.load_tracks(query) - if load_result.has_error: + log.debug(f"{load_result.load_type=}") + if load_result.has_error or load_result.load_type != LoadType.TRACK_LOADED: 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 @@ -66,6 +69,7 @@ class AudioSession(TriviaSession): self.player.add(self.ctx.author, tracks[0]) if not self.player.current: + log.debug("Pressing play") await self.player.play() continue_ = await self.wait_for_answer(answers, delay, timeout) From bf81d7c1573a86026d26fc3c15befde72486b34e Mon Sep 17 00:00:00 2001 From: bobloy Date: Wed, 23 Sep 2020 11:57:17 -0400 Subject: [PATCH 2/3] Embeds and track variable --- audiotrivia/audiosession.py | 9 ++++++--- audiotrivia/audiotrivia.py | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/audiotrivia/audiosession.py b/audiotrivia/audiosession.py index 04d53c2..1bdff02 100644 --- a/audiotrivia/audiosession.py +++ b/audiotrivia/audiosession.py @@ -58,15 +58,18 @@ class AudioSession(TriviaSession): log.info(f"Track has error: {load_result.exception_message}") continue # Skip tracks with error tracks = load_result.tracks - seconds = tracks[0].length / 1000 + + track = tracks[0] + seconds = track.length / 1000 if self.settings["repeat"] and seconds < delay: + # Append it until it's longer than the delay tot_length = seconds + 0 while tot_length < delay: - self.player.add(self.ctx.author, tracks[0]) + self.player.add(self.ctx.author, track) tot_length += seconds else: - self.player.add(self.ctx.author, tracks[0]) + self.player.add(self.ctx.author, track) if not self.player.current: log.debug("Pressing play") diff --git a/audiotrivia/audiotrivia.py b/audiotrivia/audiotrivia.py index ec7b5ea..0bab980 100644 --- a/audiotrivia/audiotrivia.py +++ b/audiotrivia/audiotrivia.py @@ -84,24 +84,24 @@ class AudioTrivia(Trivia): self.audio: Audio = self.bot.get_cog("Audio") if self.audio is None: - await ctx.send("Audio is not loaded. Load it and try again") + await ctx.maybe_send_embed("Audio is not loaded. Load it and try again") return categories = [c.lower() for c in categories] session = self._get_trivia_session(ctx.channel) if session is not None: - await ctx.send("There is already an ongoing trivia session in this channel.") + await ctx.maybe_send_embed("There is already an ongoing trivia session in this channel.") return status = await self.audio.config.status() notify = await self.audio.config.guild(ctx.guild).notify() if status: - await ctx.send( + await ctx.maybe_send_embed( f"It is recommended to disable audio status with `{ctx.prefix}audioset status`" ) if notify: - await ctx.send( + await ctx.maybe_send_embed( f"It is recommended to disable audio notify with `{ctx.prefix}audioset notify`" ) @@ -110,12 +110,12 @@ class AudioTrivia(Trivia): if not ctx.author.voice.channel.permissions_for( ctx.me ).connect or self.audio.is_vc_full(ctx.author.voice.channel): - return await ctx.send("I don't have permission to connect to your channel.") + return await ctx.maybe_send_embed("I don't have permission to connect to your channel.") await lavalink.connect(ctx.author.voice.channel) lavaplayer = lavalink.get_player(ctx.guild.id) lavaplayer.store("connect", datetime.datetime.utcnow()) except AttributeError: - return await ctx.send("Connect to a voice channel first.") + return await ctx.maybe_send_embed("Connect to a voice channel first.") lavaplayer = lavalink.get_player(ctx.guild.id) lavaplayer.store("channel", ctx.channel.id) # What's this for? I dunno @@ -123,7 +123,7 @@ class AudioTrivia(Trivia): await self.audio.set_player_settings(ctx) if not ctx.author.voice or ctx.author.voice.channel != lavaplayer.channel: - return await ctx.send( + return await ctx.maybe_send_embed( "You must be in the voice channel to use the audiotrivia command." ) @@ -135,13 +135,13 @@ class AudioTrivia(Trivia): try: dict_ = self.get_audio_list(category) except FileNotFoundError: - await ctx.send( + await ctx.maybe_send_embed( "Invalid category `{0}`. See `{1}audiotrivia list`" " for a list of trivia categories." "".format(category, ctx.prefix) ) except InvalidListError: - await ctx.send( + await ctx.maybe_send_embed( "There was an error parsing the trivia list for" " the `{}` category. It may be formatted" " incorrectly.".format(category) @@ -152,7 +152,7 @@ class AudioTrivia(Trivia): continue return if not trivia_dict: - await ctx.send( + await ctx.maybe_send_embed( "The trivia list was parsed successfully, however it appears to be empty!" ) return From f05a8bf4f60f0f2fcb7f9188c3514d080a3f385b Mon Sep 17 00:00:00 2001 From: bobloy Date: Wed, 23 Sep 2020 12:07:20 -0400 Subject: [PATCH 3/3] *some* games fixed --- audiotrivia/data/lists/games.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/audiotrivia/data/lists/games.yaml b/audiotrivia/data/lists/games.yaml index c3a9078..4de795a 100644 --- a/audiotrivia/data/lists/games.yaml +++ b/audiotrivia/data/lists/games.yaml @@ -1,13 +1,13 @@ AUTHOR: Plab -https://www.youtube.com/watch?v=--bWm9hhoZo: +https://www.youtube.com/watch?v=f9O2Rjn1azc: - Transistor -https://www.youtube.com/watch?v=-4nCbgayZNE: +https://www.youtube.com/watch?v=PgUhYFkVdSY: - Dark Cloud 2 - Dark Cloud II -https://www.youtube.com/watch?v=-64NlME4lJU: +https://www.youtube.com/watch?v=1T1RZttyMwU: - Mega Man 7 - Mega Man VII -https://www.youtube.com/watch?v=-AesqnudNuw: +https://www.youtube.com/watch?v=AdDbbzuq1vY: - Mega Man 9 - Mega Man IX https://www.youtube.com/watch?v=-BmGDtP2t7M: