我试图用discord py slash commands lib在cogs中发送一个按钮,但问题是wait_for_component
不起作用,我在控制台中没有收到任何错误,但如果我单击按钮,它会显示交互失败!这是我的齿轮文件
import discord
from discord.ext import commands
from discord_slash.context import ComponentContext
from discord_slash.model import ButtonStyle
from discord_slash.utils.manage_components import create_actionrow, create_button, wait_for_component
class buttons(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def button(self, ctx):
btns = [create_button(
style=ButtonStyle.green,
label="Button!"
)]
action_row = create_actionrow(*btns)
await ctx.send("My Message", components=[action_row])
button_ctx: ComponentContext = await wait_for_component(self.client,components=actionrow)
await button_ctx.edit_origin(content="You pressed a button!")
def setup(client):
client.add_cog(buttons(client))
目前没有回答
相关问题 更多 >
编程相关推荐