#Running add_reaction outside await function
1 messages · Page 1 of 1 (latest)
How come it doesn't work
AttributeError: '_asyncio.Task' object has no attribute 'add_reaction'
moji = bot.loop.create_task(bot.get_channel(979395372214538304).send(embed=embed))
if get_random_poll[3] != "None":
bot.loop.create_task(moji.add_reaction("1️⃣"))
= AttributeError: '_asyncio.Task' object has no attribute 'add_reaction'
why are u creating a task to get a channel?
Is a await functionn
oh thats sending
Yeah, combination haha
u just not using async or something?
I use schedule, that doesnt support Async stuff
schedule.every().day.at("18:30").do(get_question)
get_question is the function, cant add await before it
why not use a async scheduler
uh, get channel is sync
fetch is async
you don't need a task to use get_channel here
Ah okey
But issue with add_reaction stays
There isnt a work around?
Its also sending the message btw
your issue is that create_task returns an asyncio.Task, not whatever the coroutine inside returns
just make a helper function that does all three things (get emoji, send embed, add reaction), then call that one function inside a task
Ah okey, will try that later when i'm behind the pc again!
^
apscheduler
Because working with .create_task within sync context is pain
using an async scheduler will be better in the long run anyways
Check!