discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.37k stars 3.97k forks source link

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

Open advaith1 opened 11 months ago

advaith1 commented 11 months ago

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:

https://github.com/discordjs/discord.js/blob/e412a22ceb92f142fbeddb6b9330e046bec92c69/packages/discord.js/src/structures/BaseInteraction.js#L63-L67

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 commented 10 months ago

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?