'discord py buttons triggered multiple times
So im Making a Voice Support Bot in discord py and im stuck on a problem with the Buttons to Close the case or report abuse.
This is the Code where it sends the embed with the Buttons (This works)
import discord
from discord.ext import commands
from discord_ui import Button, UI
@bot.event
async def on_voice_state_update(member, before, after):
try:
if after.channel.id == int("944642625351327784"):
if before.channel is None and after.channel is not None:
notifychannel = bot.get_channel(944642626055979059)
embed = discord.Embed(title="test")
notifyembed = await ui.components.send(notifychannel, embed=embed, components=[
Button("Close", f"close-{uservoicechannel.id}", "green", emoji="✅"),
Button("Abuse!", f"abuse-{uservoicechannel.id}", "red", emoji="🛠️", new_line=False)
])
except:
pass
And this is the Code where it listens to the Button Click:
@bot.listen("on_button")
async def on_button(btn):
print(btn.component.custom_id)
Everything works but when there are 3 Channel open and someone clicks on ONE Button its triggered 3 times.
Is there a way to fix this maybe disable the button with the custom id or some?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
