'Grant role on button click discord.py

#rules embed is made earlier on
rulesbutton = Button(label="Accept Rules", custom_id = "rulesbutton", color="green", emoji="📜")
    await ctx.send(embed=rules, components=[rulesbutton])

    interaction = await client.wait_for("button_click", check= lambda i: i.custom_id == 'rulesbutton')
    await interaction.send(content="Role Added!", ephermal=True)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source