Reputation: 11
I am new to Discord API.
I am trying to send messages to my discord channel using a bot. I would like to run the function "scheduled_run" so that it sends messages to the channel.
Below code should send "Remainder" to channel but I am receiving error "can't send non-None value to a just-started coroutine"
async def get_channel(id):
return
async def scheduled_run():
channel = get_channel(83863944137526xxxx)
await channel.send("Remainder")
if __name__ == "__main__":
loop = get_event_loop()
loop.run_until_complete(scheduled_run())
Error: Traceback (most recent call last): File "main.py", line 83, in loop.run_until_complete(scheduled_run()) File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "main.py", line 78, in scheduled_run await channel.send(msg) TypeError: can't send non-None value to a just-started coroutine
Is it possible to send bot message without user reply? Please correct my code
Upvotes: 1
Views: 360
Reputation: 1362
You must fetch the channel directly from client:
channel = client.get_channel(83863944137526xxxx)
await channel.send("Remainder")
Upvotes: 0