【问题标题】:discord.py bot doesnt respond to Bot.commands()discord.py bot 不响应 Bot.commands()
【发布时间】:2020-02-22 10:34:04
【问题描述】:

您好,我正在创建一个不和谐的机器人,我试图添加单个命令,但机器人不响应任何命令

类似

Bot = commands.Bot(command_prefix="!")
@Bot.commands()
async def ping():
    print("Pong!")

当我输入 !ping 到 discord 客户端时,这个东西应该会响应它应该将 pong 打印到终端 但什么都没有 我试过 Bot.add_command(ping) 但它说命令它已经注册了我不知道..

【问题讨论】:

标签: python discord discord.py-rewrite


【解决方案1】:

根据我从 discord.py 文档中读到的内容,您应该像这样编写代码:

Bot = commands.Bot(command_prefix="!")

@Bot.commands() 
async def ping(ctx):
    ctx.send("Pong!")

当您使用“打印”时,您会在空闲终端上打印答案。 'ctx.send' 在不和谐聊天中打印答案。 discord.py 上的每个函数都需要和参数。

【讨论】:

    猜你喜欢
    • 2020-09-12
    • 2021-04-01
    • 2021-10-16
    • 2021-04-09
    • 2019-02-26
    • 1970-01-01
    • 2021-06-22
    • 2021-01-19
    • 1970-01-01
    相关资源
    最近更新 更多