0
votes

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 :)

1
What is your discord.py version?Nurqm
Where is bot defined?Wavened
i have bot defined. this is half of the code i should've mentioned that. my discord.py version is 1.5.1D3crypt360

1 Answers

1
votes

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.