Value "user" is not a snowflake

I’m creating a discord bot to DM a user with the command /warn. However, I’m getting this error: DiscordAPIError[50035]: Invalid Form Body recipient_id[NUMBER_TYPE_COERCE]: Value "user" is not snowflake. My replit.

You’re passing the string “user” to client.users.send() in your warn command, instead of the user id

You should be doing this:

} else if (interaction.commandName == 'warn') {
     const content = interaction.options.get('message').value;
     const userId = interaction.options.get('user').value;
     const user = await client.users.fetch(userId);
     user.send(content); // Send the warning message to the user
     interaction.reply({ content: `Successfully warned ${user}.`, ephemeral: true});

Remember that, you first get the userId from the interaction options, then fetch the user using client.users.fetch(userId) . Aaand, after that, you use the send() method on the user object to send the warning message to the user.

1 Like

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