i tried
const ownerId = guild.fetchOwner();
console.log(ownerId.tag)
i get undefined
same thing when im evaluating it
message.guild.ownerId.tag
list of testing eval
- message.guild.ownertag = undefined
- message.guild.ownerTag = undefined
- message.guild.owner.tag = undefined
- message.guild.owner.Tag = undefined
- message.guild.ownerId.tag = undefined
- message.guild.ownerId.Tag = undefined
- message.guild.ownerId = (my_id/guild_owner_id)
- message.guild.fetchOwner() = (<@my_id>/<@guild_owner_ID>)
please help me out
CodePudding user response:
guild.fetchOwner()
returns a promise, you need to add await
.
const ownerId = await guild.fetchOwner();
// also, you need to access the user property before trying to get the user tag
console.log(ownerId.user.tag);
CodePudding user response:
There is also another way to fetch the owner if you want to do it synchronously. You can use guild.ownerId
to get the id of the owner and then guild.members.cache.get()
to get the owner. An example:
const ownerId = guild.ownerId
const owner = guild.members.cache.get(ownerId)
console.log(owner.user.tag)
(Note: the owner might not be cached sometimes so guild.members.cache.get()
might not return anything sometimes. I just posted this as an alternative to @Crytek1012's answer)