Command not working ( no errors on console , only your app hasnt respond )
6 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
All my commands arent working , just used this as an example
lemme check
well , i dont know how to call it , i never needed to
my commands used to work
but now they dont
also not working
const {SlashCommandBuilder, CommandInteraction, PermissionFlagsBits, EmbedBuilder} = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("clear")
.setDescription("Deleta mensagens de um usuario ou de um chat")
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
.addIntegerOption(option =>
option.setName('amount')
.setDescription('Quantidades de mensagens para deletar')
.setMinValue(1)
.setMaxValue(99)
.setRequired(true)
)
.addUserOption(option =>
option.setName('target')
.setDescription('Selecione um usuario para ter suas mensagens deletadas')
.setRequired(false)
),
async execute(interaction) {
const {channel, options} = interaction;
const amount = options.getInteger('amount');
const target = options.getUser("target");
const messages = await channel.messages.fetch({
limit: amount +1,
});
const res = new EmbedBuilder()
.setColor(0x080000)
.setAuthor({ name: 'Sunflower-Moderation', iconURL: 'https://i.imgur.com/Qy2XpGi.png'})
if(target) {
let i = 0;
const filtered = [];
(await messages).filter((msg) =>{
if(msg.author.id === target.id && amount > i) {
filtered.push(msg);
i++;
}
});
await channel.bulkDelete(filtered).then(messages => {
res.setDescription(`Foram deletadas ${messages.size} mensagens de ${target}.`);
interaction.reply({embeds: [res]});
});
} else {
await channel.bulkDelete(amount, true).then(messages => {
res.setDescription(` Foram deletadas ${messages.size} mensagens deste canal `);
interaction.reply({embeds: [res]});
});
}
}
}
const {SlashCommandBuilder, CommandInteraction, PermissionFlagsBits, EmbedBuilder} = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("clear")
.setDescription("Deleta mensagens de um usuario ou de um chat")
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
.addIntegerOption(option =>
option.setName('amount')
.setDescription('Quantidades de mensagens para deletar')
.setMinValue(1)
.setMaxValue(99)
.setRequired(true)
)
.addUserOption(option =>
option.setName('target')
.setDescription('Selecione um usuario para ter suas mensagens deletadas')
.setRequired(false)
),
async execute(interaction) {
const {channel, options} = interaction;
const amount = options.getInteger('amount');
const target = options.getUser("target");
const messages = await channel.messages.fetch({
limit: amount +1,
});
const res = new EmbedBuilder()
.setColor(0x080000)
.setAuthor({ name: 'Sunflower-Moderation', iconURL: 'https://i.imgur.com/Qy2XpGi.png'})
if(target) {
let i = 0;
const filtered = [];
(await messages).filter((msg) =>{
if(msg.author.id === target.id && amount > i) {
filtered.push(msg);
i++;
}
});
await channel.bulkDelete(filtered).then(messages => {
res.setDescription(`Foram deletadas ${messages.size} mensagens de ${target}.`);
interaction.reply({embeds: [res]});
});
} else {
await channel.bulkDelete(amount, true).then(messages => {
res.setDescription(` Foram deletadas ${messages.size} mensagens deste canal `);
interaction.reply({embeds: [res]});
});
}
}
}
y , im not asking for spoonfeed , i just wanna know the problem with my code
is that better?
commands are working now
thx for the help
aprecciate it
const { CommandInteraction, ApplicationCommandAutoComplete , InteractionType, Events} = require("discord.js");
module.exports = {
name: "interactionCreate",
async execute(interaction, client) {
const { customId, values, guild, member } = interaction;
if (interaction.isChatInputCommand()) {
const command = client.commands.get(interaction.commandName);
if (!command) {
return interaction.reply({ content: "outdated command" });
}
command.execute(interaction, client);
if(interaction.type == InteractionType.ApplicationCommandAutocomplete){
const {commands} = client;
const {commandName} = interaction;
const command = commands.get(commandName);
if (!command) return;
try {
await command.autocomplete(interaction, client)
} catch (error){
console.error(error);
}
}
},
};
const { CommandInteraction, ApplicationCommandAutoComplete , InteractionType, Events} = require("discord.js");
module.exports = {
name: "interactionCreate",
async execute(interaction, client) {
const { customId, values, guild, member } = interaction;
if (interaction.isChatInputCommand()) {
const command = client.commands.get(interaction.commandName);
if (!command) {
return interaction.reply({ content: "outdated command" });
}
command.execute(interaction, client);
if(interaction.type == InteractionType.ApplicationCommandAutocomplete){
const {commands} = client;
const {commandName} = interaction;
const command = commands.get(commandName);
if (!command) return;
try {
await command.autocomplete(interaction, client)
} catch (error){
console.error(error);
}
}
},
};