From 24ff39a2a808955bc594af07f5cc9cabbd0715f4 Mon Sep 17 00:00:00 2001 From: bain Date: Mon, 22 Aug 2022 00:12:21 +0200 Subject: [PATCH] do not remove download_error reactions --- ari/messages.py | 20 +++++++++++--------- ari/player.py | 10 ---------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/ari/messages.py b/ari/messages.py index 422fc71..373304b 100644 --- a/ari/messages.py +++ b/ari/messages.py @@ -150,15 +150,17 @@ class MessageHandler: dm = await self.client.create_dm(discord.Object(id=payload.user_id)) player = self.client.players.get(payload.guild_id) if player is None or not player.is_running(): - # error emojis should be only visible when a player is running - # this was probably fired in the split second when the player was - # turning off - return - message = f"{Emoji.download_error} ***Sorry, I was not able to play the following songs:***\n```\n" - for error in player.errored_songs: - message += f" - {error}\n" - message += "```" - await dm.send(message) + await dm.send( + f"{Emoji.download_error} ***I am not currently playing anything***\n" + f"I was not able to play some songs from this message. The error could have " + f"been temporary, you can try to play it again!" + ) + else: + content = f"{Emoji.download_error} ***Sorry, I was not able to play the following songs:***\n```\n" + for error in player.errored_songs: + content += f" - {error}\n" + content += "```" + await dm.send(content) message = await self.get_or_fetch_message( payload.message_id, payload.channel_id ) diff --git a/ari/player.py b/ari/player.py index 9365ba4..957d3c8 100644 --- a/ari/player.py +++ b/ari/player.py @@ -80,24 +80,14 @@ class Player: await asyncio.sleep(1) except CacheError: await self.add_error(music) - self.errored.add(music.content.message) self.errored_songs.add(music.content.video_id) except Exception: logger.exception(f"{hash(self)}: exception while playing") break self._running = False await self.voice.disconnect() - await self.cleanup_errors() logger.info(f"{hash(self)} player shutdown") - async def cleanup_errors(self): - for message in self.errored: - try: - await message.clear_reaction(Emoji.download_error) - except discord.HTTPException: - # the message could already be gone - pass - async def add_error(self, item: QueueItem): try: await item.content.message.add_reaction(Emoji.download_error)