Hello,
I've reviewed the persistent views page, however I'm trying to adapt it to be dynamic. Does @discord.ui.button() recognize the button based on the custom_id set or do I need to provide a message ID somewhere?
e.g. something like:
from db import main_db
import discord
giveaways = main_db["giveaways"]
class GiveawayViews(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
active = giveaways.find({"active": True})
for doc in active:
@discord.ui.button(label="Enter Giveaway", style=discord.ButtonStyle.green, custom_id=doc["id"])
async def on_button_press(self, button: discord.ui.Button, interaction: discord.Interaction):
...