#My Buttons dont work after restart

1 messages · Page 1 of 1 (latest)

plain sage
#

My Buttons dont work after restart

#

why after i restart my bot the buttons dont work anymore they should normally still work can someone tell me why?

verbal wagonBOT
#

Here's the persistent example.

solemn monolith
plain sage
#

if you look in the .txt file

solemn monolith
#

?tag codeblock

feral summitBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
solemn monolith
plain sage
#

yeah

#
class PersistentView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label="🎟️ Ticket-Support", style=discord.ButtonStyle.blurple, custom_id="ticket_button1")
    async def first_button_callback(self, button, interaction):
        ... my code is to long

class PersistentViewBot(commands.Bot):
    def __init__(self):
        super().__init__()
        self.persistent_views_added = False

    async def on_ready(self):
        if not self.persistent_views_added:
            self.add_view(PersistentView())
            self.persistent_views_added = True

bot = PersistentViewBot()
solemn monolith
#

Yeah that all looks right

plain sage
#

so why it doesnt work

#

if i restart my bot?

solemn monolith
#

What version of pycord?

plain sage
#

py-cord==2.0.0b7