有没有办法改变NextCord交互的到期持续时间?
首先,请原谅我缺乏知识和我写的不良代码。我为您的专业求和。将我从无知的深处抬起。
我目前正在使用NextCord.py库进行Discord机器人。我正在使用NextCord.UI.View,Buttons&显示一种“菜单”。嵌入。
我定义了三个不同的类,这些类别从nextcord.ui.view,一个用于主窗口,一个,一个用于设置,一个用于团队。每个代表菜单的不同层。您可以通过单击“相应的按钮”来更改图层,在该按钮下,我像这样编写了代码:
class Teams(nextcord.ui.View):
@nextcord.ui.button(label='Main window', style=nextcord.ButtonStyle.green)
async def main_window(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
await interaction.response.edit_message(view=Lobby())
@nextcord.ui.button(label='Settings', style=nextcord.ButtonStyle.gray)
async def settings(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
await interaction.response.edit_message(view=Settings())
我正在使用Interaction.Response.edit_message(view = NewView())指向菜单的新层。
我的对问题的理解是,交互在闲置3分钟后到期,然后我再也无法与菜单进行互动。 但是,如果我通过单击按钮继续与菜单进行互动,则交互不会到期。
,我的问题是,就像标题所说,是否有一种方法可以延长到期时间或可能完全删除它?我不涉及我单击按钮的一种方式:,)
我已经阅读了文档,但我尝试了许多不同的搜索单词,但是我还没有找到令人满意的解决方案。
我目前的工作是使用一个队列,该队列需要在调用菜单之前达到一定的能力。因此,当您最终调用菜单时,您更有可能使用它,而不是空转。
我也尝试完全忽略了这个问题,但是这些解决方案并不能完全满足我。 我有点新手编程,这是我的第一篇文章,请原谅任何缺点。
First of all, lords of bits, please excuse me my lack of knowledge and the possible bad code that I've written. I yarn for your expertises. Lift me up from the depths of my ignorance.
I'm currently working on a discord bot using nextcord.py library. I am displaying a sort of 'menu' using nextcord.ui.View, buttons & embeds.
I have defined three different classes which inherit from nextcord.ui.View, one for the main window, one for settings and one for teams. Each represent a different layer of the menu. You change layers by clicking the corresponding button, under which I have written code like so:
class Teams(nextcord.ui.View):
@nextcord.ui.button(label='Main window', style=nextcord.ButtonStyle.green)
async def main_window(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
await interaction.response.edit_message(view=Lobby())
@nextcord.ui.button(label='Settings', style=nextcord.ButtonStyle.gray)
async def settings(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
await interaction.response.edit_message(view=Settings())
I am using interaction.response.edit_message(view=NewView()) to point to a new layer of the menu.
My understanding of the problem is that the interaction expires after being idle for 3 minutes(?) after which I can no longer interact with the menu.
However, if I keep interacting with the menu by means of clicking the buttons, the interaction does not expire.
So, my question is, like the title says, is there a way to extend the expiration time or possibly completely remove it? A way that does not involve me clicking the buttons :,)
I have read through the documents and I've tried numerous different search words, but I have not found a satisfying solution.
My current work-around is to use a queue which needs to reach a certain capacity before you can call the menu. So, when you finally do call the menu, you are more likely to use it, instead of idling.
I also tried completely ignoring the problem, but these solutions do not fully satisfy me.
I'm kinda new to programming and this is my first post, please excuse any shortcomings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的班级团队中,您应该制作 init 方法。然后使用super()函数使超时=无。
In your class Teams, you should make a init method. Then use the super() function to make the timeout = None.