I'm coding a server-info
command for my discord bot, and I want to get the owner username or tag from the actual guild. I found a way to do it in discord js 11, but it's not working anymore under 12th version :
const guild = client.guilds.get(message.guild.id);
message.channel.send(message.guild.member(guild.owner) ? guild.owner.toString() : guild.owner.user.tag);
// if the user is in that guild it will mention him, otherwise it will use .tag
So in discord js 12, client.guilds.get
isn't a function, and guild.owner
returns null
.
message.guild.owner.user.username
is also returning Cannot read property 'user' of null
.
I took a look at the documentation, and message.guild.owner
seems to be a real property (https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=owner). So I don't know why it's returning null.
client.guilds.get()
function? – Lioness100console.log(message.guild)
and see if there is an ownerID. – Worthy Alpacaguild
const tomessage.guild.id
, but now,message.guild.id.owner
is undefined – IturielownerID
in theguild
object. See if you have that.console.log(message.guild.ownerID)
– Worthy Alpaca