gpt4 book ai didi

python - 尝试运行命令 'ctx is a required argument that is missing' 时收到错误。 [Python, discord.py]

转载 作者:行者123 更新时间:2023-12-04 15:19:37 25 4
gpt4 key购买 nike

您好,当我尝试运行命令时出现此错误:

忽略命令 greet discord.ext.commands.errors.MissingRequiredArgument 中的异常:ctx 是缺少的必需参数

当我尝试使用 pass_context=True 手动传递上下文时(我知道我认为这已经过时了)它出现了:AttributeError: 'Context' 对象没有属性 'send'

我在各种论坛上到处查看,我发现其他人也有同样的问题,但答案总是针对那个用户的问题,因此对我来说毫无用处或者已经过时,没有使用重写。如果有人能提供帮助,我将不胜感激。

有谁知道我为什么会收到这个问题以及我该如何解决它?

以下是我认为有用的代码部分:

    @client.command()
async def greet(ctx):
await ctx.send("Hello")

这是完整的代码:https://pastebin.com/fQc4vE7F

编辑:我使用的是 discord 版本 1.4.1,以防可能有用

最佳答案

你应该尝试重新安装 discord.py,同时确保将以下内容放在顶部:

from discord.ext import commands
import discord

关于python - 尝试运行命令 'ctx is a required argument that is missing' 时收到错误。 [Python, discord.py],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63620014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com