Home > Net >  client.guilds.cache.get(...). members.get It is not a function
client.guilds.cache.get(...). members.get It is not a function

Time:06-13

I'm doing a command with cargo, this error comes and I can't understand it, here's the script:

const member = client.guilds.cache.get('980553630480474232').members.get(interaction.user.id); 

And here is the error: client.guilds.cache.get(...).members.get is not a function.

CodePudding user response:

In v13, you need to use .cache.get(), if the error persists double check your guild ID.

If you encounter such an error try console.log() to see wich value is undefined, because such errors results from having undefined values.

And for future advice if you need a value more than once in your code define it first, in this case use

const guild = client.guilds.cache.get('980553630480474232');
const member = guild.members.cache.get('ID')

Side Note: If this is a command file, you can directly get the guild using:

interaction.guild.members.get(interaction.user.id)
  • Related