Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a d.js object instead of a raw member object for interactions from uncached guilds #10010

Open
advaith1 opened this issue Dec 1, 2023 · 1 comment

Comments

@advaith1
Copy link
Contributor

advaith1 commented Dec 1, 2023

Which application or package is this feature request for?

discord.js

Feature

Currently, interaction.member can either be a discord.js member object or a raw Discord member object:

/**
* If this interaction was sent in a guild, the member which sent it
* @type {?(GuildMember|APIGuildMember)}
*/
this.member = data.member ? this.guild?.members._add(data.member) ?? data.member : null;

this is a painful API because these two objects are very different. I understand that d.js GuildMember requires a guild object, but a partial object that doesn't require a guild object would be much better than falling back to a completely separate format.

most d.js bots would probably error on accessing member data if they get added to a guild without the bot scope, since people are probably not handling the raw member case.

Ideal solution or implementation

Introducing a new partial guild member class that takes a guild ID rather than a full guild object. It should support as much of GuildMember's interface as is possible to implement without having a full guild object. interaction.member should create an object of this class if the guild is uncached.

Alternative solutions or implementations

No response

Other context

this is currently an issue for adding apps with only the applications.commands scope, and it is also an issue for user apps, which will probably be used a lot more than the former.

@Benzo-Fury
Copy link

Benzo-Fury commented Jan 3, 2024

I've been looking into this a little. Im curious tho, what would be the cause for discord.js actually returning a APIGuildMember instead of a normal GuildMember?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants