do not remove download_error reactions

This commit is contained in:
bain 2022-08-22 00:12:21 +02:00
parent 4ad40c3ddd
commit 24ff39a2a8
No known key found for this signature in database
GPG key ID: A708F07AF3D92C02
2 changed files with 11 additions and 19 deletions

View file

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

View file

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