Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Discord.py 使用process_命令时出现错误消息_Discord.py - Fatal编程技术网

Discord.py 使用process_命令时出现错误消息

Discord.py 使用process_命令时出现错误消息,discord.py,Discord.py,我收到一条错误消息,原因是命令进程\ u命令和命令不起作用,而EVNT确实起作用 import discord from discord import commands import os bot = commands.Bot(command_prefix="!") client = discord.Client() @client.event async def on_ready(): print('Logged in as as {0.user}'.forma

我收到一条错误消息,原因是命令进程\ u命令和命令不起作用,而EVNT确实起作用

import discord
from discord import commands
import os

bot = commands.Bot(command_prefix="!")
client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as as {0.user}'.format(client))
 
@client.event
async def on_message(message):
  if message.author == client.user:
    return

  if message.content.startswith('Hello'):
    await message.channel.send('Hello!')

#here comes the error message
  await bot.process_commands(message)

#this command doesn't work
@bot.command()
async def testymesty(ctx):
  await ctx.send('test')

keep_alive()
client.run(os.environ['TOKEN'])

简单错误,您将客户端定义为commands.bot,那么它将是: 等待客户端处理命令(消息) 在客户端和bot之间做出决定


不要同时使用客户端和bot

您必须使用客户端或bot,使用bot,删除不一致。客户端已定义,并将所有表示客户端的内容更改为botOh,好的,谢谢,现在它工作了!但是你能解释一下commands.Bot和discord.client之间的区别吗?我相信
commands.Bot
discord.client的一个稍微扩展的版本。好的,非常感谢你的帮助!