.getMember() with Typescript

I saw that options.getMember() sometimes doesn't return a GuildMember. How can I filter this case out?
No description
14 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
TÆMBØ
TÆMBØ2mo ago
With a condition statement There is no second parameter to specify whether the option is required or not to narrow it down as someone can simply paste in the ID of a user who is not in the guild that the command was ran in, resulting in you getting a user for them but not a member Ahhh, scratch that, you must be referring to the "raw" object
d.js docs
d.js docs2mo ago
:method: CommandInteraction#inCachedGuild() @14.16.3 Indicates whether this interaction is received from a cached guild.
LukeZ
LukeZOP2mo ago
uhm, I really meant "When is the second type returned?" 😅
Kinect3000
Kinect30002mo ago
When the guild isn’t cached
TÆMBØ
TÆMBØ2mo ago
When the interaction you receive is from a guild that's not cached
LukeZ
LukeZOP2mo ago
and then addtionally "How can I filter this?" When does this happen? I have all guilds cached usually.
TÆMBØ
TÆMBØ2mo ago
User-installable app Added to a guild without the bot scope No Guilds intent
Kinect3000
Kinect30002mo ago
Also custom cache settings/removing guilds from cache manually
TÆMBØ
TÆMBØ2mo ago
This typeguard filters that out
LukeZ
LukeZOP2mo ago
that.... is dumb. Understandable, but a problem I think. Could I just fetch the guild when a guild isn't cached or something similar?
TÆMBØ
TÆMBØ2mo ago
If your app actually has access to the guild, sure
Amgelo
Amgelo2mo ago
if it isn't a user installable app and you have the Guilds intent (most of the time you do) then you could just return if it isn't cached, instead of having to handle that case manually
LukeZ
LukeZOP2mo ago
okay, thank you both very much! ^^ it's not a user-app so that would not be the cause
Want results from more Discord servers?
Add your server