From 6504169758cebf84d985d78d58f64fa9f768d060 Mon Sep 17 00:00:00 2001 From: lnguy Date: Sun, 18 Feb 2024 11:05:04 +0100 Subject: [PATCH] Fix feedback button bugs --- src/main.py | 2 ++ src/module/button.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index 3752b97..d7e9f86 100644 --- a/src/main.py +++ b/src/main.py @@ -33,6 +33,8 @@ async def on_ready(self): if not self.synced: await tree.sync() self.synced = True + action_channel = self.get_channel(actioned_channel_id) + self.add_view(view=button.DoneButton(action_channel)) print('Logged on as', self.user) diff --git a/src/module/button.py b/src/module/button.py index 20ae4bb..974b65d 100644 --- a/src/module/button.py +++ b/src/module/button.py @@ -1,19 +1,23 @@ +import random + +import sys + import discord class DoneButton(discord.ui.View): def __init__(self, actioned_channel): self.actioned_channel = actioned_channel - super().__init__() + super().__init__(timeout=None) - @discord.ui.button(label="👍", style=discord.ButtonStyle.green) + @discord.ui.button(label="👍", style=discord.ButtonStyle.green, custom_id="Done") async def done(self, interaction: discord.Interaction, button: discord.ui.Button): done_message = "{} \nactioned by **{}** with 👍\n".format( interaction.message.content, interaction.user.name) await self.actioned_channel.send(content=done_message) await interaction.message.delete() - @discord.ui.button(label="👎", style=discord.ButtonStyle.red) + @discord.ui.button(label="👎", style=discord.ButtonStyle.red, custom_id="Cancel") async def cancel(self, interaction: discord.Interaction, button: discord.ui.Button): done_message = "{} \nactioned by **{}** with 👎\n".format( interaction.message.content, interaction.user.name)