Subclassing Button class for each button, changing context interface for handlers

This commit is contained in:
Rafael Vargas
2022-07-27 17:20:57 -03:00
parent 4f11506c2b
commit ca754c6f62
36 changed files with 227 additions and 85 deletions

24
UI/Buttons/BackButton.py Normal file
View File

@@ -0,0 +1,24 @@
from discord import ButtonStyle, Interaction
from discord.ui import Button
from Config.Emojis import VEmojis
from Handlers.PrevHandler import PrevHandler
from Music.VulkanBot import VulkanBot
class BackButton(Button):
def __init__(self, bot: VulkanBot):
super().__init__(label="Back", style=ButtonStyle.secondary, emoji=VEmojis().BACK)
self.__bot = bot
async def callback(self, interaction: Interaction) -> None:
await interaction.response.defer()
handler = PrevHandler(interaction, self.__bot)
response = await handler.run()
print(response)
print(response.success)
print(response.error)
print(response.error)
print(response.embed)
if response.embed:
await interaction.followup.send(embed=response.embed)