Property 'voice' does not exist on type 'GuildMember | APIInteractionGuildMember'.

Hi, how can I make this typesafe?
if (!interaction.member?.voice?.channel) {
return await interaction.reply({
content: "You need to enter a voice channel before use the command",
ephemeral: true,
});
}
if (!interaction.member?.voice?.channel) {
return await interaction.reply({
content: "You need to enter a voice channel before use the command",
ephemeral: true,
});
}
  I'm getting the error in the title Property 'voice' does not exist on type 'GuildMember | APIInteractionGuildMember'.
4 Replies
d.js toolkit
d.js toolkit2w 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!
d.js docs
d.js docs2w ago
:method: ChatInputCommandInteraction#inCachedGuild() @14.16.3 Indicates whether this interaction is received from a cached guild.
feldrok
feldrokOP2w ago
is there a better way to accessing the current user's voice channel active members? as it says cached, how can i make sure this is updated data? I have google quite a lot regarding this but can't seem to find the best solution
Kinect3000
Kinect30002w ago
The guild should always be cached Keep Guilds intent enabled (d.js is pretty much useless w/o this). And don’t intentionally uncache guilds and channels
Want results from more Discord servers?
Add your server