简体   繁体   中英

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

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM