Discord API Error 50035: Value null is not snowflake

Getting the following error when executing an xp leaderboard command:
DiscordAPIError[50035]: Invalid Form Body
user_id[NUMBER_TYPE_COERCE]: Value “null” is not snowflake.
at SequentialHandler.runRequest (C:\Users\jacob\OneDrive\Escritorio\Bot\node_modules@discordjs\rest\dist\index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\Users\jacob\OneDrive\Escritorio\Bot\node_modules@discordjs\rest\dist\index.js:712:14)
at async REST.request (C:\Users\jacob\OneDrive\Escritorio\Bot\node_modules@discordjs\rest\dist\index.js:1321:22)
at async UserManager.fetch (C:\Users\jacob\OneDrive\Escritorio\Bot\node_modules\discord.js\src\managers\UserManager.js:91:18)
at async Object.execute (C:\Users\jacob\OneDrive\Escritorio\Bot\src\commands\Community\xpleaderboard.js:33:35)
at async Object.execute (C:\Users\jacob\OneDrive\Escritorio\Bot\src\events\interactionCreate.js:15:13) {
rawError: {
code: 50035,
errors: { user_id: [Object] },
message: ‘Invalid Form Body’
code: 50035,
status: 400,
method: ‘GET’,
url: ‘https://discord.com/api/v10/users/null’,
requestBody: { files: undefined, json: undefined }


const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder, DiscordAPIError } = require('discord.js');
const levelSchema = require(`../../Schemas.js/level`)
module.exports = {
    data: new SlashCommandBuilder()
    .setDescription('This gets a servers xp leaderboard'),
    async execute(interaction) {
        const { guild, client } = interaction;
        let text = "";
        const embed1 = new EmbedBuilder()
        .setDescription(`<:redcheck:1015276845077364848>  No one is on the leaderboard yet...`)
        const Data = await levelSchema.find({ Guild: guild.id})
                XP: -1,
                Level: -1
            if (!Data) return await interaction.reply({ embeds: [embed1]})
            await interaction.deferReply()
            for(let counter = 0; counter < Data.length; ++counter) {
                let { User, XP, Level } = Data[counter]
                    const value = await client.users.fetch(User) || "Unknown Member"
                    const member = value.tag;
                    text += `${counter + 1}. ${member} | XP: ${XP} | Level: ${Level} \n`
                    const embed = new EmbedBuilder()
                        .setTitle(`${interaction.guild.name}'s XP Leaderboard:`)
                        .setFooter({ text: `XP Leaderboard` })
                   interaction.editReply({ embeds: [embed] })

it does say you’ve passed “null” where it needed a snowflake. and it gave you a backtrace of where this happened. do you know how to read a backtrace?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.