Aquí está el código de mi módulo de comando de Discord, por alguna razón esto dice que .addArgument no es una función.
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.`); } );Solo me da esto:
TypeError: (valor intermedio).setName(...).setDescription(...).addArgument no es una función
La razón por la que recibe este error es porque no hay nada llamado .addArgument() en SlashCommandBuilder . Si desea agregar argumentos como números o canales, debe usar .addNumberOption() o .addChannelOption() . La forma en que deberá usar para agregar una opción de canal y número es así:
.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() })Puede obtener más información sobre los comandos de barra y las opciones aquí => Opciones | discordia.js