我有一个非常基本的脚本,它会弹出一条带有命令按钮的消息?位置
单击此按钮后,机器人会向单击它的用户回复Hi.
如果按钮未与进行交互,则为>;大约3分钟后,它开始返回"交互失败".
之后按钮就没用了.我假设在文档中找不到某种内部超时.无论是否使用discord,按钮都会执行相同的操作.py(2.0)或pycord.没有任何东西击中控制台.就好像没有点击按钮一样.
偶尔按钮会再次工作,控制台会出现大量错误:
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
Ignoring exception in view <View timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='click me' emoji=None row=None>:
我假设超时=180是导致此问题的原因,但是否有人知道如何停止此超时以及它发生的原因?我在文档中看不到任何关于discord按钮只能使用3分钟的内容.
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix="?", intents=intents)
embed1=discord.Embed(title="Test", description = f"TESTING",color=0xffffff)
print("bot connected")
@ bot.command(name='place')
async def hello(ctx):
view = discord.ui.View()
buttonSign = discord.ui.Button(label = "click me", style= discord.ButtonStyle.green)
async def buttonSign_callback(interaction):
userName = interaction.user.id
embedText = f"test test test"
embed=discord.Embed(title="Test", description = embedText,color=0xffffff)
await interaction.response.send_message(f"Hi <@{userName}>")
buttonSign.callback = buttonSign_callback
view.add_item(item=buttonSign)
await ctx.send(embed = embed1,view = view)
bot.run(TOKEN)