import discord
import asyncio
import asyncpg
from discord.ext import commands
async def on_message(message):
channel = client.get_channel('654057661142269964')
await channel.send('verify')
await client.send_message(message.channel, "Test")
return
client.run(Token)
这就是我在Python3.7中使用的代码,但问题是我在Discord上没有得到响应,尽管我得到了错误:
line 13, in on_message
await channel.send('verify')
AttributeError: 'NoneType' object has no attribute 'send'
首先,您混合了不同版本的不和谐.py.
Client.send_message
来自不和谐.pyv0.16,一个过时的版本,不再受支持。你应该调查一下migrating to v1。 注意,id实际上是该版本中的字符串。在v1更新后的最新版本中,它们只是整数。你知道吗不管怎样,正如the documentation for^{} 所说,如果找不到通道,它将返回
None
。您需要在使用之前添加一个检查,以查看是否找到了该频道。你知道吗相关问题 更多 >
编程相关推荐