1
0
Fork 0

Clear action miss some vars and update list now check if the message still exists

This commit is contained in:
Ethanell 2020-04-10 19:10:03 +02:00
parent c961274377
commit 4bb5695bd4

View file

@ -208,7 +208,9 @@ class Speak(commands.Cog):
self.voice_chan = None self.voice_chan = None
if self.last_message: if self.last_message:
await self.last_message.delete() await self.last_message.delete()
self.last_message = None
await self.voice_message.delete() await self.voice_message.delete()
self.voice_message = None
@commands.Cog.listener() @commands.Cog.listener()
async def on_reaction_remove(self, reaction: Reaction, user: Member): async def on_reaction_remove(self, reaction: Reaction, user: Member):
@ -221,21 +223,22 @@ class Speak(commands.Cog):
await self.update_list(reaction.message.channel.guild) await self.update_list(reaction.message.channel.guild)
async def update_list(self, guild: Guild): async def update_list(self, guild: Guild):
persons = [] if self.voice_message:
if len(self.reaction) != 0: persons = []
for i, reaction in enumerate(self.reaction): if len(self.reaction) != 0:
persons.append(f"Reaction N°{i+1}: {guild.get_member(reaction).display_name}") for i, reaction in enumerate(self.reaction):
for i, speaker in enumerate(self.waiting): persons.append(f"Reaction N°{i+1}: {guild.get_member(reaction).display_name}")
persons.append(f"{i+1}: {guild.get_member(speaker).display_name}") for i, speaker in enumerate(self.waiting):
if len(persons) == 0: persons.append(f"{i+1}: {guild.get_member(speaker).display_name}")
persons = "Nobody" if len(persons) == 0:
else: persons = "Nobody"
persons = "\n".join(persons) else:
embed = self.voice_message.embeds[0] persons = "\n".join(persons)
field = embed.fields[0] embed = self.voice_message.embeds[0]
embed.remove_field(0) field = embed.fields[0]
embed.insert_field_at(0, name=field.name, value=persons, inline=True) embed.remove_field(0)
await self.voice_message.edit(embed=embed) embed.insert_field_at(0, name=field.name, value=persons, inline=True)
await self.voice_message.edit(embed=embed)
@commands.Cog.listener() @commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error): async def on_command_error(self, ctx: commands.Context, error):