guild.fetchOwner() is returning a collection of guild members
See original GitHub issueWhich package is this bug report for?
discord.js
Issue description
Using Discord 13.6.0 I am trying to get the id of the guild, is not working for me.
Trying guild.ownerId
returns undefined, but I was then directed to try guild.fetchOwner()
, but this returns a list of members of the guild instead of a GuildMember
.
Looking at the Discord source code suggests that if guild.ownerId
is undefined, this will return all the members of the guild:
``js fetchOwner(options) { return this.members.fetch({ …options, user: this.ownerId }); }
### Code sample
```typescript
To get the guild:
async getGuild (guildId?: string) {
const client = await this.getClient();
const guildResolvable = client.guilds.resolveId(guildId || this.guildId);
const guild = client.guilds.resolve(guildResolvable);
if (!guild) {
throw new Error('Unable to access guild');
}
return guild;
}
This returns a guild with `ownerId` being `undefined, but then calling `guild.fetchOwner()` returns a collection of form `Collection(11) [Map] { ... }`.
Package version
13.6.0
Node.js version
16.6.0
Operating system
macOS
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
GuildMembers, GuildMessages
I have tested this issue on a development release
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to get owner of a guild in discord.js v13? - Stack Overflow
fetchOwner() method on it, which returns us a promise with when fulfilled returns us the GuildMember object of the owner.
Read more >is it possible to get guild owner tag in discord.js v13?
ownerId const owner = guild.members.cache.get(ownerId) ... guild.fetchOwner() returns a promise, you need to add await .
Read more >Discord.js v13 Guild Owner name of multiple servers. - Reddit
guild.fetchOwner it only returns Undefined, as you can't use await in a forEach loop, thought the loop might be able to grab the...
Read more >discord.js-codemod - npm
Discord.js codemod scripts.. Latest version: 1.0.1, last published: a year ago. Start using discord.js-codemod in your project by running ...
Read more >Updating from v12 to v13 - discord.js Guide
The Guild#owner property has been removed as it was unreliable due to caching, replaced with Guild#fetchOwner . - console.log(guild.owner); + ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I just noticed through extra experimenting, though it wasn’t clear from the documentation:
https://discord.js.org/#/docs/discord.js/stable/class/Guild?scrollTo=fetchOwner
Also, would it be possible to have code provide clarity on this, such as:
Though, not sure if that fits with the API’s philosophy?
Although I don’t agree with this particular error message, I do think this method should reject if
guild.ownerId
isn’t defined. It’s designed to fetch a single GuildMember. If it cannot do so, it should reject.The current behaviour where in an edge case it can return a Collection of GuildMembers is not the expected result and should be considered a bug.