discord.py按钮超时
我是UI接口(按钮)的新手。以下代码是我的Discord机器人的一部分
button1 = Button(style=discord.ButtonStyle.blurple, emoji='⬅')
button2 = Button(style=discord.ButtonStyle.blurple, emoji='➡')
view = View()
view.add_item(button1)
view.add_item(button2)
*some embed code*
message = await ctx.send(embed=embedVar, view=view)
,我想在我的两个按钮上添加超时,并在某个时候禁用它们,但是我正在努力,因为文档上没有示例(不使用子类)。我该怎么办?
I'm new to the ui interface (buttons). This following code is a part of my discord bot
button1 = Button(style=discord.ButtonStyle.blurple, emoji='⬅')
button2 = Button(style=discord.ButtonStyle.blurple, emoji='➡')
view = View()
view.add_item(button1)
view.add_item(button2)
*some embed code*
message = await ctx.send(embed=embedVar, view=view)
Here I want to add a timeout to both of my buttons and disable them after sometime, but I'm struggling a bit as there is no example on the docs (without using subclasses). How can I do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它替换您的
用
内容在该视图中为所有组件添加了超时。
参考: https:// discordpy.readthedocs.io/en/latest/interactions/api.html?highlight = view#discord.ui.ui.view.timeout
Replace your
with
It adds a timeout to all components in that View.
Reference: https://discordpy.readthedocs.io/en/latest/interactions/api.html?highlight=view#discord.ui.View.timeout