Unkown User

node:events:496
throw er; // Unhandled 'error' event
^

DiscordAPIError[10013]: Unknown User
at handleErrors (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:1149:23)
at async SequentialHandler.queueRequest (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:980:14)
at async _REST.request (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:1293:22)
at async UserManager.fetch (C:\Users\danea\Desktop\MF BOT\node_modules\discord.js\src\managers\UserManager.js:95:18)
at async Object.execute (C:\Users\danea\Desktop\MF BOT\src\events\strikeEvents.js:27:30)
at emitUnhandledRejectionOrErr (node:events:401:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Unknown User', code: 10013 },
code: 10013,
status: 404,
method: 'GET',
url: 'https://discord.com/api/v10/users/710658239393431700'
}
node:events:496
throw er; // Unhandled 'error' event
^

DiscordAPIError[10013]: Unknown User
at handleErrors (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:1149:23)
at async SequentialHandler.queueRequest (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:980:14)
at async _REST.request (C:\Users\danea\Desktop\MF BOT\node_modules\@discordjs\rest\dist\index.js:1293:22)
at async UserManager.fetch (C:\Users\danea\Desktop\MF BOT\node_modules\discord.js\src\managers\UserManager.js:95:18)
at async Object.execute (C:\Users\danea\Desktop\MF BOT\src\events\strikeEvents.js:27:30)
at emitUnhandledRejectionOrErr (node:events:401:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Unknown User', code: 10013 },
code: 10013,
status: 404,
method: 'GET',
url: 'https://discord.com/api/v10/users/710658239393431700'
}
18 Replies
d.js toolkit
d.js toolkit6mo 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!
GhostBear9
GhostBear9OP6mo ago
Using data.
//Grabbing the data relating to the message.
const data = await strikeSchema.findOne({ messageId: interaction.message.id })

//Checking if there is still data.
if(!data) {

//Replying to the interaction.
interaction.reply({ content: `Unable to kick user use /kick instead!`, flags: MessageFlags.Ephemeral })

}

//Getting the user.
const user = await client.users.fetch(`${data.userId}`)
//Grabbing the data relating to the message.
const data = await strikeSchema.findOne({ messageId: interaction.message.id })

//Checking if there is still data.
if(!data) {

//Replying to the interaction.
interaction.reply({ content: `Unable to kick user use /kick instead!`, flags: MessageFlags.Ephemeral })

}

//Getting the user.
const user = await client.users.fetch(`${data.userId}`)
Saving data.
//Creating kick message data.
await strikeSchema.create({
messageId: kickMessage.id,
userId: options.getUser('user').id
})
//Creating kick message data.
await strikeSchema.create({
messageId: kickMessage.id,
userId: options.getUser('user').id
})
If anyone could help that would be great I am new to JS.
Amgelo
Amgelo6mo ago
what is your strikeSchema
GhostBear9
GhostBear9OP6mo ago
const { Schema, model } = require('mongoose');

let newSchema = new Schema({
messageId: Number,
userId: Number,
});

module.exports = model('strikeSchema', newSchema);
const { Schema, model } = require('mongoose');

let newSchema = new Schema({
messageId: Number,
userId: Number,
});

module.exports = model('strikeSchema', newSchema);
Using mongodb
d.js docs
d.js docs6mo ago
tag suggestion for @GhostBear9: - Discord ids follow the snowflake format: learn more - Discord ids must be represented as strings as they are larger than Number.MAX_SAFE_INTEGER, the largest integer that can be represented in JavaScript
- client.guilds.cache.get(123456789012345678)
+ client.guilds.cache.get("123456789012345678")
- client.guilds.cache.get(123456789012345678)
+ client.guilds.cache.get("123456789012345678")
Amgelo
Amgelo6mo ago
you cannot save it and then retrieve it as a number it'll be a different one truncated to be less than the max safe integer
GhostBear9
GhostBear9OP6mo ago
So should I save it as a string? Then convert it as needed?
Amgelo
Amgelo6mo ago
you don't need it to convert it anywhere though unless you're doing math with it?
GhostBear9
GhostBear9OP6mo ago
No not really I guess.
Amgelo
Amgelo6mo ago
if you are then you'd need a bigint then yeah you don't need to convert
GhostBear9
GhostBear9OP6mo ago
Okay I'll try storing it as a string then, I bet it will work. Thank you so much!
bread
bread6mo ago
it may seem a database issue tho, the code itself seems fine, have you debugged it? or use .toString() when grabbing
GhostBear9
GhostBear9OP6mo ago
Yea
bread
bread6mo ago
im sure it should have that option
GhostBear9
GhostBear9OP6mo ago
I've tried a lot but it works now.
bread
bread6mo ago
perfect
GhostBear9
GhostBear9OP6mo ago
Also looked back at my other code and previously I have stored user ids as strings.
bread
bread6mo ago
oh yea, you wont use numbers at all in discord.js

Did you find this page helpful?