Skip to content

Commit

Permalink
Fix feedback button bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
TLNBS2405 committed Feb 18, 2024
1 parent 7467cdb commit 6504169
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
10 changes: 7 additions & 3 deletions src/module/button.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 6504169

Please sign in to comment.