问题是我写了一些我认为是正确的代码,但是显然它是不正确的,所以我想问你们,因为您可能会更了解
@bot.event
async def on_message(message):
if message.author == bot.user:
print(message.author,message.content)
return
print(message.author,message.content)
channel = bot.get_channel(576705173766930433)
await channel.send('{0.author}: {0.message}'.format(message))
当我发送消息时,控制台将对此表示反对: 忽略on_message中的异常
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 255, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Servant_Of_Paschen.py", line 38, in on_message
await channel.send('{0.author}: {0.message}'.format(message))
AttributeError: 'str' object has no attribute 'author'
答案 0 :(得分:0)
对不起,我一个人发现了
await channel.send('{}: {}'.format(message.author, message.content))
是我想做的事