Reputation: 130
So i want to make a command that always keeps running till something changed and when that something changes it will send a message to a channel which i have specified However, I keep getting an error.
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())
Here is the error:
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'
any help would be appreciated :)
Upvotes: 0
Views: 138
Reputation: 2540
You are attempting to use the channel before the bot is ready. Try adding the following line before the channel = bot.get_channel(766572517367873556)
line.
await bot.wait_until_ready()
Aside - Please double check your indentation.
Upvotes: 1