How do I pass the self.canCraft variable into the decorator? I understand the problem why it doesn't work, but I cant find a solution. I dont want to do it with a global variable.
class CraftView(discord.ui.View):
def __init__(self, viewOwner, craftItem, canCraft):
super().__init__()
self.viewOwner = viewOwner
self.craftItem = craftItem
self.canCraft = canCraft
@discord.ui.button(label="Craft", style=discord.ButtonStyle.primary, emoji="", disabled=self.canCraft)
async def button_callback(self, interaction: Interaction, button: ui.Button):
pass
You're probably better off subclassing discord.ui.Button and adding it to a view like so-