Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
discord.js - TypeError [COMMAND_INTERACTION_OPTION_TYPE]: Option "user" is of type: STRING; expected USER

When I run the script for my discord bot and use /warn remove it keeps throwing an error that user is of type string expected USER. It says the error is happening between lines 69:42 and I can't find the issue.

module.exports = {
    category: 'Moderation',
    description: 'Warn a user',

    permissions: ['ADMINISTRATOR'],
    
    slash: true,
    guildOnly: true,

    options: [
        {
            type: 'SUB_COMMAND',
            name: 'remove',
            description: 'Removes a warning from the user',
            options: [
                {
                    name: 'user',
                    type: 'USER',
                    description: 'The user to remove the warning from',
                    required: true,
                },
                {
                    name: 'id',
                    type: 'STRING',
                    description: 'The ID of the warning to remove',
                    required: true,
                },
            ],
        }
    ],

    callback: async ({ guild, member: staff, interaction }) => {
        const user = interaction.options.getUser('user')

        if (subCommand === 'remove') {
            const warning = await warnSchema.findByIdAndDelete(id)

            return {
                custom: true,
                content: `Removed warning ${warning.id} from  <@${user?.id}>`,
                allowedMentions: {
                    users: []
                }
            }
        }
    }
}

I didn't post all the code because it seemed like it would be too much searching but this is the code that is causing the error.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!