Python 尝试请求bot时出错

Python 尝试请求bot时出错,python,discord,Python,Discord,好的,所以我在repl.it上使用python构建了一个discord机器人 问题是,我的机器人甚至显示它是在线的,但每当我键入$hello时,它就会在我脸上抛出一个巨大的错误 这就是错误所在 忽略on_消息回溯中的异常(最近一次呼叫最后一次): 文件 “/opt/virtualenvs/python3/lib/python3.8/site packages/discord/client.py”, 第343行,运行事件中 等待on_消息中第21行的coro(*args,**kwargs)文件“

好的,所以我在repl.it上使用python构建了一个discord机器人 问题是,我的机器人甚至显示它是在线的,但每当我键入$hello时,它就会在我脸上抛出一个巨大的错误

这就是错误所在

忽略on_消息回溯中的异常(最近一次呼叫最后一次):
文件 “/opt/virtualenvs/python3/lib/python3.8/site packages/discord/client.py”, 第343行,运行事件中 等待on_消息中第21行的coro(*args,**kwargs)文件“main.py” wait message.send.channel('Hello there young shona follower!')AttributeError:'message'对象没有属性'send'


这个错误是不言自明的。您不能在
on\u message
函数中的
对象上调用
send
方法。

它是
message.channel.send
,而不是
message.send.channel

wait message.channel.send('Hello there young shona follower!')
import os
import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

@client.event
async def on_message(message):

  if message.author == client.user:
    return

  if message.content.startswith('$hello'):
    await message.send.channel('Hello there young shona follower!')

client.run(TOKEN)