I'm trying to fetch members from a guild using their ID but now the variable I'm using returns Undefined

All this was working fine an hour ago but now discord.js refuses to fetch members from a guild using their ID.

let target = message.guild.members.cache.fetch(args[0])

And I have not changed anything at all from when it was working.
I have no idea how this could occur but I’m confused as hell.

Note: args[0] is a string. A user ID from the first argument in a message.

16 thoughts on “I'm trying to fetch members from a guild using their ID but now the variable I'm using returns Undefined”

  1. I’m not sure how it worked. There is no .fetch() method on the .cache property and it returns a promise so you need to await the member:

    let target = await message.guild.members.fetch(args[0]);
    

    enter image description here

    Reply

Leave a Comment