【发布时间】:2020-10-22 07:16:54
【问题描述】:
所以我想创建一个始终运行的命令,直到发生变化,当发生变化时,它会向我指定的频道发送消息但是,我不断收到错误消息。
import requests
from bs4 import BeautifulSoup
url = "url"
s = BeautifulSoup(requests.get(url)._content, "lxml")
canonical = s.find('link', {'rel': 'canonical'})
result = canonical['href']
async def test():
if result == url:
channel = bot.get_channel(766572517367873556)
await channel.send("checking.....\n"+ url + "\n(1) result Found")
await asyncio.sleep(10)
bot.loop.create_task(test())
这是错误:
File "C:path\bot.py", line 91, in patch
await channel.send("checking.....\n"+ url + "\n(1) result Found")
AttributeError: 'NoneType' object has no attribute 'send'
任何帮助将不胜感激:)
【问题讨论】:
-
你的 discord.py 版本是多少?
-
bot 是在哪里定义的?
-
我已经定义了机器人。这是我应该提到的代码的一半。我的 discord.py 版本是 1.5.1
标签: python discord discord.py