roh
roh

Reputation: 43

Async function | Await not waiting for promise {Partially D.js}

async function find(a) {await message.guild.members.resolve(a).displayName}

let Del = find("350994324072300547")
message.channel.send(Del)

I want Del to "be" message.guild.members.resolve("350994324072300547").displayName and for find to wait for the promise.. What am I doing wrong?

The result I get is [object Promise]

Upvotes: 0

Views: 226

Answers (1)

Vasanth Gopal
Vasanth Gopal

Reputation: 1285

Include await to the find call. And wrap the entire code in a IIFE async function.

(async function() {
    async function find(a) {
       return await message.guild.members.resolve(a).displayName
    }

    let Del = await find("350994324072300547");

    message.channel.send(Del);
})();

Upvotes: 1

Related Questions