Permanent button panels.

Sometimes with discord bots you want to create a button that persists in a channel for users to click. Whether its a way to weed out spam bots or a way to create a ticket for your ticketing system bot. I struggled for a bit finding a way to get this done. This was my solution using the library Dislash.

@inter_client.slash_command(name="create_button", description="Creates a panel for your button channel")
async def create_button2(ctx):
    embed = discord.Embed(
        title="Click Button to gain access to the features of this server!",
        color=0x00ff00
    )
    row = ActionRow(
        Button(style=ButtonStyle.green, label="Button Name", custom_id="ex_button")
    )
    await ctx.send(embed=embed, components=[row])

@bot.event
async def on_button_click(res):
    embed = discord.Embed(
        title="Click Button to gain access to the features of this server!",
        color=0x00ff00
    )
    row = ActionRow(
        Button(style=ButtonStyle.green, label="Button Name", custom_id="ex_button")
    )
    if res.component.custom_id == "ex_button":
        user = res.author
        dm_channel = user.dm_channel or await user.create_dm()
        await button_action(res) # put the function where you want the buttons actions to take place
        await res.respond(type=6)
        await asyncio.sleep(1)
        await res.channel.send(embed=embed, components=[row])

An example of what this results in: