小编Leg*_*rad的帖子

Discord.py 按钮响应交互在一段时间后失败

我有一个非常基本的脚本,它会弹出一条消息,其中包含带有命令 ?place 的按钮

单击此按钮后,机器人会向单击它的用户回复“嗨”。

如果按钮没有交互超过大约 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>:
Run Code Online (Sandbox Code Playgroud)

我认为超时 = 180 是此问题的原因,但有人知道如何停止此超时以及为什么会发生这种情况吗?我在文档中看不到任何关于不和谐按钮只能使用 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 …
Run Code Online (Sandbox Code Playgroud)

python timeout discord discord.py pycord

4
推荐指数
1
解决办法
1万
查看次数

多字不一致斜杠命令 (PyCord)

我正在使用 pycord 制作一组简单的斜杠命令来实现不和谐。

import discord


bot = discord.Bot()

testingServer = [{server ID}]

@bot.slash_command(guild_ids = testingServer, name ="verify_help", description="blabla" )
async def verifyHelp(ctx):

    embed=discord.Embed(title="Verify Your Wallet", description = "help goes here",color=0xffffff)


    await ctx.respond(embed = embed, ephemeral=True)

bot.run({TOKEN})

Run Code Online (Sandbox Code Playgroud)

我相信可以创建多字斜线命令,如不和谐 API 文档中所示:

即使用斜杠命令作为 /verify help 而不是 /verify-help

https://discord.com/developers/docs/interactions/application-commands

我相信我需要将“选项”部分翻译成 pycord 但不知道语法。它建议并列出选项,因此 options = []。这就是我被困住的地方。

lashcommand 的 pycord 手册在这里:https ://docs.pycord.dev/en/master/api.html#slashcommand

python slash discord discord.py pycord

3
推荐指数
1
解决办法
5590
查看次数

标签 统计

discord ×2

discord.py ×2

pycord ×2

python ×2

slash ×1

timeout ×1