我正在尝试构建一个不和谐的机器人,它会告诉你天气状况。但无论我做了什么,我都无法执行最简单的命令,例如:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command()
async def test(ctx, arg):
await ctx.send(arg)
client = discord.Client()
client.run(token)
我就是不明白。我在聊天屏幕上输入命令"!test hello“,结果什么也没发生。请帮帮忙,谢谢!
发布于 2021-09-13 20:57:56
问题是,您首先使用bot = commands.Bot(command_prefix="!")
定义机器人,然后将命令添加到机器人,然后使用client = discord.Client()
创建一个新客户端,然后运行客户端。这里的问题是,你从来没有运行机器人,它有命令,所以不是
client = discord.Client()
client.run(token)
使用
bot.run(token)
https://stackoverflow.com/questions/69169150
复制