getInteger('amount')

can someone help me, why this doesn't works? ty module.exports = { data: new SlashCommandBuilder() .setName('clear') .setDescription('Cancella una quantità di messaggi') .addIntegerOption(option => option.setName('amount').setDescription('Quantità di messaggi da eliminare').setMinValue(1).setMaxValue(20).setRequired(true)), async execute(interaction) { if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) { return interaction.reply({ content: "Non hai il permesso di cancellare i messaggi!", ephemeral: true }); } let number = interaction.options.getInteger('amount'); const embed = new EmbedBuilder() .setColor("Blue") .setDescription(:white_check_mark: Cancellati ${number} messaggi); await interaction.channel.bulkDelete(number); const button = new ActionRowBuilder() .addComponents( new ButtonBuilder() .setCustomId('cancella') .setEmoji('🗑') .setStyle(ButtonStyle.PRIMARY) ); const message = await interaction.reply({ embeds: [embed], components: [button] }); const collector = message.createMessageComponentCollector(); collector.on("collect", async i => { if (i.customId === 'cancella') { if (!i.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return; interaction.deleteReply(); } }); } };
No description
17 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
FeroxNotMonday
FeroxNotMonday8mo ago
It's not this slash. Make sure you have created it and also restart your discord client
thaferra
thaferraOP8mo ago
that's it...and I tried restarting my client several times
Svitkona
Svitkona8mo ago
when you are deploying your commands, log the command and inspect the log see if the options are there
thaferra
thaferraOP8mo ago
I was thinking about it though, but I don't know, should I put an error for each part? Have I made any progress? xd module.exports = { data: new SlashCommandBuilder() .setName('clear') .setDescription('Cancella una quantità di messaggi') .addIntegerOption(option => option.setName('amount') .setDescription('Numero di messaggi da cancellare') .setRequired(true)), async execute(interaction) { if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessagesS)) { return interaction.reply({ content: "Non hai il permesso di cancellare i messaggi!", ephemeral: true }); } const amount = interaction.options.getInteger('amount'); if (amount < 1 || amount > 20) { return interaction.reply({ content: 'Specifica un numero compreso tra 1 e 20 di messaggi da cancellare.', ephemeral: true }); } try { await interaction.channel.bulkDelete(amount + 1); return interaction.reply({ content: Cancellati ${amount} messaggi., ephemeral: true }); } catch (error) { console.error(error); return interaction.reply({ content: 'Si è verificato un errore durante la cancellazione dei messaggi.', ephemeral: true }); } }, }; nope
thaferra
thaferraOP8mo ago
ok, i'd resolved
No description
thaferra
thaferraOP8mo ago
but now i've this other "problem"
No description
thaferra
thaferraOP8mo ago
nope
thaferra
thaferraOP8mo ago
No description
FeroxNotMonday
FeroxNotMonday8mo ago
this is different
thaferra
thaferraOP8mo ago
No description
FeroxNotMonday
FeroxNotMonday8mo ago
this is different
thaferra
thaferraOP8mo ago
uhm then no
FeroxNotMonday
FeroxNotMonday8mo ago
in this code you create a command and a response to it, but you still need to handle it
thaferra
thaferraOP8mo ago
maybe I understood
thaferra
thaferraOP8mo ago
like that?
No description
FeroxNotMonday
FeroxNotMonday8mo ago
It doesn't look very good, but technically it is
Want results from more Discord servers?
Add your server