Mongonesa
Mongonesa

Reputation: 35

Is it possible to access a class attribute in a python decorator?

Is it possible to access a class attribute in a python decorator?

Code:

class ButtonView(discord.ui.View):
  def __init__(self, allPages, author, *, timeout = 180):
    super().__init__(timeout=timeout)
    self.allPages = allPages

  @discord.ui.button(label=self.allPages, style=discord.ButtonStyle.secondary, custom_id="current_page_button")
  async def current_page_button_callback(self, button, interaction):
    ...

I get a warning on self.allPages in @discord.ui.button():

self.allPages is not defined

Upvotes: 1

Views: 88

Answers (0)

Related Questions