Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
.addArgument is not a function Discord bot

Here is my Discord command module code, for some reason this is spitting out that .addArgument is not a function.

const Discord = require('discord.js');
const { SlashCommandBuilder } = require('@discordjs/builders');

data = new SlashCommandBuilder()
    .setName('purge')
    .setDescription('Purges a number of messages from the channel.')
    .addArgument('number', 'The number of messages to purge.')
    .addArgument('channel', 'The channel to purge messages from.')
    .setExecute(async (interaction, args) => {
        const channel = interaction.guild.channels.cache.find(c => c.name === args.channel);
        if (!channel) return interaction.reply('Channel not found.');
        const messages = await channel.messages.fetch({ limit: args.number });
        await channel.bulkDelete(messages);
        interaction.reply(`Purged ${messages.size} messages.`);
    }

);

It just gives me this:

TypeError: (intermediate value).setName(...).setDescription(...).addArgument is not a function

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The reason you are getting this error is because there is nothing called .addArgument() in the SlashCommandBuilder. If you want to add arguments like numbers or channels, you need to use .addNumberOption() or .addChannelOption(). The way you will need to use to add a channel and number option is like this:

.addNumberOption(option => {
    return option
        .setName('number') // Set the name of the argument here
        .setDescription('The number of messages to purge.') // Set the description of the argument here
        .setRequired() // This is optional. If you want the option to be filled, you can just pass in true inside the .setRequired() otherwise you can just remove it
})
.addChannelOption(option => {
    return option
        .setName('channel') 
        .setDescription('The channel to purge messages from.')
        .setRequired()
})

You can learn more about slash commands and options here => Options | discord.js

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda