Untitled
unknown
python
a year ago
2.9 kB
4
Indexable
class VotoSimView(discord.ui.View): def __init__(self): super().__init__() aprovou = [] reprovou = [] aprovados = '0' reprovados = '0' self.add_item(self.VotoSimBotao(label=aprovados, style=discord.ButtonStyle.green, emoji='<:yes:1260045636443701248>',aprovou=aprovou, reprovou=reprovou, aprovados=aprovados, reprovados=reprovados)) self.add_item(self.VotoNaoBotao(label=reprovados, style=discord.ButtonStyle.red, emoji='<:no:1260045637525704835>', reprovou=reprovou, aprovou=aprovou, aprovados=aprovados, reprovados=reprovados)) class VotoSimBotao(discord.ui.Button): def __init__(self, label, style, emoji, aprovou, reprovou, aprovados, reprovados): super().__init__(label=label, style=style, emoji=emoji) self.aprovou=aprovou self.reprovou=reprovou self.aprovados=aprovados self.reprovados=reprovados global reprovados global aprovados async def callback(self, interaction: discord.Interaction): if interaction.user.id in self.reprovou: self.reprovou.remove(int(interaction.user.id)) self.reprovados=int(self.reprovados)-1 self.label=int(self.label)+1 self.aprovou.append(int(interaction.user.id)) await interaction.response.edit_message(view=VotoSimView()) await interaction.followup.send('Votação removida.', ephemeral=True) else: if interaction.user.id in self.aprovou: self.label = int(self.label)-1 self.aprovou.remove(int(interaction.user.id)) await interaction.message.edit(view=self.view) await interaction.response.send_message("Votação registrada com sucesso.", ephemeral=True) else: self.label = int(self.label)+1 self.aprovou.append(int(interaction.user.id)) await interaction.message.edit(view=self.view) await interaction.response.send_message("Votação registrada com sucesso.", ephemeral=True) class VotoNaoBotao(discord.ui.Button): def __init__(self, label, style, emoji, reprovou, aprovou, aprovados, reprovados): super().__init__(label=label, style=style, emoji=emoji) self.reprovou=reprovou self.aprovou=aprovou self.aprovados=aprovados self.reprovados=reprovados async def callback(self, interaction: discord.Interaction): self.reprovou.append(int(interaction.user.id)) self.label = int(self.label)+1 await interaction.message.edit(view=self.view) await interaction.response.send_message("Votação registrada com sucesso.", ephemeral=True)
Editor is loading...
Leave a Comment