Issue
I'm trying to add a functionality to my discord bot to send a certain message every 10 seconds (content of the message is not important right now). Here's my code:
@client.event
async def on_ready():
await client.wait_until_ready()
await client.loop.create_task(update_task())
async def update_task():
await client.wait_until_ready()
chn = client.get_channel('#')
while True:
await chn.send('message')
await asyncio.sleep(10)
and I get the error:
AttributeError: 'NoneType' object has no attribute 'send'
I've seen couple of similar questions already and all of the solutions are to add
await client.wait_until_ready()
before, but this doesn't work for me and I still get the error. Does anyone have a clue on how to fix this?
Solution
This isn't working because get_channel()
requires an int type object that equals an id belonging to a channel the bot can access. For example, this would be a correct usage:
channel = client.get_channel(700437301263728720)
Answered By - Konyer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.