#Unknown User
1 messages · Page 1 of 1 (latest)
But my code is:
let member = message.mentions.members.first() || await message.guild.members.fetch({ user: args[0], force: true })
@terse urchin
And I already have a line that checks if member.user is an object.
then you need to elaborate what you mean by known user, I thought that was what you meant
Well...
A friend of mine used the command wrong, and instead of the userID first, he did the messageID first.
Sort of... I am getting the error 'Unknown User'
Do you get what I mean? @terse urchin
Unknown User
Can you show the full error + stack
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Unknown User
at RequestHandler.execute (/home/runner/StormMC-Discord-Bot/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/runner/StormMC-Discord-Bot/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async GuildMemberManager._fetchSingle (/home/runner/StormMC-Discord-Bot/node_modules/discord.js/src/managers/GuildMemberManager.js:407:18) {
method: 'get',
path: '/guilds/948561490552684544/members/950860734668103711',
code: 10013,
httpStatus: 404,
requestData: { json: undefined, files: [] }
}
I know, it was a messageID. But how can I make it so it will then return an error if it isn't a UserID?
Where 🤣
let args = message.content.split(" ")
args.shift()
let member = message.mentions.members.first() || await message.guild.members.fetch({ user: args[0], force: true })
args.shift()
let SuggestionID = args.join(" ")
if(!member.user) return message.reply("Je moet wel even zeggen wie de suggestie heeft ingevoerd, zodat ik diegene op de hoogte kan brengen!")
Or... Do I have to catch .fetch()?
yeah you can chain a catch onto it, which will probably result in it returning undefined
So you'd want to optional chain member?.user
Or yoiu can try/catch the whole block
no, it isnt
Explain...
It will catch the error from the Promise rejecting and allow you to handle it
Since you're using await, awaiting it will resolve to the value of what the .catch function returns (not a member)
So you still need to check it
But that is what it should do...
If it is not a member, it should return an error.
.catch() does this, I just tested it out.
Or am I wrong into that?
"return" to where though? Im not sure what you mean
Just returning a message that it isn't a user.