#promize a message
1 messages · Page 1 of 1 (latest)
i dont see a point to promisifying a promise
you'll see in a few seconds
okay
but i'm new on promise async await
i may do shit
but i don't know how to do else than my way :/
just explain why you need to promisify a promise
yup
Ok
I have a piece of code in that file who are using a token stored in a database
uhuh
The problem is that I need to refresh this token
yeah
and only user can do it (thanks to faceit :/)
yeah i still dont get you
the bot in that way need to ask for the new token
awaitMessage returns a promise after the user chats
yeah so why do you need to promisify it
i dont see a need for that
you can just use async await or return the resolved data from the promise of the "other function"
do you know how promises work?
🥴
I have an idea
you see where my problem is ? x)
no
uh
you literally
resolve the promise
it will wait for the promise to finish
before executing the code
// pseudo-code
function fn returns promise;
var data = await fn(); // await resolves the promise, so no code after this line will run until the promise is resolved
serious ?!
so it will return "undifined" in this case
i do not understand
why
you need to make everything a promise
async function fn() returns a promise too
no need to use new Promise
and you can use await
please learn what promises are, without this knowledge i really have no clue how to help you
c# is not js
I know
promises are not threads
but the bacground work is the same
In what way are they different
omg i really
i have no clue how to get this through to you
that you dont promisify a promise
I know that (And I'm not proud of it) but I have no clues how to make that functionnal and cleaner
they dont even need threads
I know, the purpose of a promize is to block the main script and do his stuff
in that way the main script can get the response of the promise
that's what i need
then just resolve the promise from awaitMessages?
ok i really
dont know how to help you
im sorry for wasting your time
and my own time
i hope you find the solution somewhere but i have no clue how to help anymore
I will run the code without the promize
ok that's what i'm gessing i'm getting undifined