首页 > 解决方案 > Discord 机器人在特定输入上说出特定内容

问题描述

我在 python 中为 discord 编写了一个小机器人,并开始使用简单的 $print 函数,但是当你输入一个特定的单词时,我想添加一个简单的函数,比如$cat它返回cats are good或者可能是一只猫的图像/gif。我试着用这个来做。

@bot.command(NAME="hello")
    await ctx.channel.send("hi there")

基本上,我想在输入hi there时输出$hello。但是当我尝试运行 python 文件时,它会立即崩溃

标签: pythondiscorddiscord.py

解决方案


代码几乎是错误的

以下是修改后的代码:

@bot.command()
async def hello(ctx):
    await ctx.send("hi there")

推荐阅读