.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 toolkit3mo 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Ø3mo 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 docs3mo ago
:method: CommandInteraction#inCachedGuild() @14.16.3 Indicates whether this interaction is received from a cached guild.
LukeZ
LukeZOP3mo ago
uhm, I really meant "When is the second type returned?" 😅
Kinect3000
Kinect30003mo ago
When the guild isn’t cached
TÆMBØ
TÆMBØ3mo ago
When the interaction you receive is from a guild that's not cached
LukeZ
LukeZOP3mo ago
and then addtionally "How can I filter this?" When does this happen? I have all guilds cached usually.
TÆMBØ
TÆMBØ3mo ago
User-installable app Added to a guild without the bot scope No Guilds intent
Kinect3000
Kinect30003mo ago
Also custom cache settings/removing guilds from cache manually
TÆMBØ
TÆMBØ3mo ago
This typeguard filters that out
LukeZ
LukeZOP3mo 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Ø3mo ago
If your app actually has access to the guild, sure
Amgelo
Amgelo3mo 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
LukeZOP3mo 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