有没有办法改变 nextcord 交互的到期时间?

is there a way to alter the expiration duration of nextcord interactions?

首先,各位大佬,请见谅我的知识匮乏和我写的可能不好的代码。我纱你的专业知识。把我从无知的深渊中拉起来。

我目前正在使用 nextcord.py 库开发一个 discord 机器人。我正在使用 nextcord.ui.View、按钮和嵌入显示一种 'menu'。

我定义了三种不同的 类,它们继承自 nextcord.ui.View,一种用于主要 window,一种用于设置,一种用于团队。每个代表菜单的不同层。您可以通过单击相应的按钮来更改图层,我在该按钮下编写了如下代码:

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分钟(?)后过期,之后我无法再与菜单交互。 但是,如果我继续通过单击按钮与菜单进行交互,则交互不会过期。

所以,我的问题是,如标题所说,有没有办法延长过期时间或者可能完全删除它?一种不需要我点击按钮的方式:,)

我已经通读了文档,也尝试了很多不同的搜索词,但我没有找到满意的解决方案。

我目前的work-around是使用queue需要达到一定容量才能调用菜单。所以,当你最终调用菜单时,你更有可能使用它,而不是闲置。

我也尝试过完全忽略这个问题,但这些解决方案并不能完全让我满意。 我是编程新手,这是我的第一次编程 post,如有不足请多多包涵。

在您的 class 团队中,您应该创建一个 init 方法。然后使用super()函数使timeout = None.

class Teams(nextcord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    """All Buttons you create in here will have no timeout"""