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)) dm = await self.client.create_dm(discord.Object(id=payload.user_id))
player = self.client.players.get(payload.guild_id) player = self.client.players.get(payload.guild_id)
if player is None or not player.is_running(): if player is None or not player.is_running():
# error emojis should be only visible when a player is running await dm.send(
# this was probably fired in the split second when the player was f"{Emoji.download_error} ***I am not currently playing anything***\n"
# turning off f"I was not able to play some songs from this message. The error could have "
return f"been temporary, you can try to play it again!"
message = f"{Emoji.download_error} ***Sorry, I was not able to play the following songs:***\n```\n" )
else:
content = f"{Emoji.download_error} ***Sorry, I was not able to play the following songs:***\n```\n"
for error in player.errored_songs: for error in player.errored_songs:
message += f" - {error}\n" content += f" - {error}\n"
message += "```" content += "```"
await dm.send(message) await dm.send(content)
message = await self.get_or_fetch_message( message = await self.get_or_fetch_message(
payload.message_id, payload.channel_id payload.message_id, payload.channel_id
) )

View file

@ -80,24 +80,14 @@ class Player:
await asyncio.sleep(1) await asyncio.sleep(1)
except CacheError: except CacheError:
await self.add_error(music) await self.add_error(music)
self.errored.add(music.content.message)
self.errored_songs.add(music.content.video_id) self.errored_songs.add(music.content.video_id)
except Exception: except Exception:
logger.exception(f"{hash(self)}: exception while playing") logger.exception(f"{hash(self)}: exception while playing")
break break
self._running = False self._running = False
await self.voice.disconnect() await self.voice.disconnect()
await self.cleanup_errors()
logger.info(f"{hash(self)} player shutdown") 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): async def add_error(self, item: QueueItem):
try: try:
await item.content.message.add_reaction(Emoji.download_error) await item.content.message.add_reaction(Emoji.download_error)