ari

discord music bot
git clone git://git.bain.cz/ari.git
Log | Files | Refs

commit 24ff39a2a808955bc594af07f5cc9cabbd0715f4
parent 4ad40c3ddd0968fe4f9ae1d85722e705e02ce2f5
Author: bain <bain@bain.cz>
Date:   Mon, 22 Aug 2022 00:12:21 +0200

do not remove download_error reactions

Diffstat:
Mari/messages.py | 20+++++++++++---------
Mari/player.py | 10----------
2 files changed, 11 insertions(+), 19 deletions(-)

diff --git 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 @@ -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)