Search code examples
javascriptdiscord.jsowner

Fetch All Discord Servers Owners


So I want to get the name of all the discord server owners that my bot is in. Discord.js v14

I tried using this:

const Guilds = client.guilds.cache.map(guild => guild.fetchOwner());
console.log(Guilds);

But it returned me this: Promise { <pending> }

I also tried this: Get server owners from what servers the bot is in, but it does not work on discord.js v14


Solution

  • You have to use Promise#all() to wait for all the promises to resolve

    const owners = await Promise.all(client.guilds.cache.map(guild => guild.fetchOwner()));
    console.log(owners);