【发布时间】:2021-05-18 16:10:17
【问题描述】:
好的,所以我在 repl.it 上使用 python 构建了一个不和谐机器人 问题是我的机器人甚至显示它在线但是每当我输入 $hello 它只会在我脸上抛出一个大错误 This is the photo of my code and the error
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)
这就是错误
忽略 on_message Traceback 中的异常(最近一次调用最后一次):
文件 “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, 第 343 行,在 _run_event await coro(*args, **kwargs) 文件“main.py”,第 21 行,on_message await message.send.channel('Hello there young shona follower!') AttributeError: 'Message' object has no attribute 'send'
【问题讨论】: