1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Update Discord Bot Code Without Losing Embed Interactions

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 15:52.

  1. Stack

    Stack Membro Participativo

    I'm making a discord bot using python, but whenever my bot posts an embed with interactable buttons, and then I rerun or deploy a new update of the bot's code, when I try to interact with that button, interaction fails. Is there anyway to keep the embed interactable even after rerunning the code?

    Here is an example code:

    menu = View()
    open_button = Button(
    label=os.getenv("CLOSE_TICKET_COMMAND_OPEN_TICKET"),
    style=discord.ButtonStyle.secondary
    )
    open_button.callback = self.open_ticket_callback
    menu.add_item(open_button)

    delete_button = Button(
    label=os.getenv("CLOSE_TICKET_COMMAND_DELETE_TICKET"),
    style=discord.ButtonStyle.danger
    )
    delete_button.callback = self.delete_ticket_callback
    menu.add_item(delete_button)

    embed = discord.Embed(
    title="",
    description=os.getenv("CLOSE_TICKET_COMMAND_CLOSED_BY").format(
    user=interaction.user.mention),
    color=discord.Color(5308575)
    )
    await channel.send(embed=embed, view=menu)

    I've tried resending the embed everytime I restart the code, but I want a more efficient sulotion. Thanks for reading.

    Continue reading...

Compartilhe esta Página