Not just one but all the commands don't work

Not just one but all the commands don't work
35 Replies
d.js toolkit
d.js toolkit10mo 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 staff
chewie
chewie10mo ago
then your command handler broke
d.js docs
d.js docs10mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
If no command works for me, is there any way to fix it? Still not working
chewie
chewie10mo ago
.
Harnes
Harnes10mo ago
also #how-to-get-help
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
What is the console.log is it a file or is it the normal console.
Harnes
Harnes10mo ago
You don't know what console log is?
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
Because I am Spanish and that's why I don't understand what the console.log thing is.
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
This?
No description
Harnes
Harnes10mo ago
You're missing a execute function Probably in your command
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
But it's not just 1, it's in all commands Do you want me to send you a sample of one of my commands?
Harnes
Harnes10mo ago
Yeah and also send your command handler
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
INDEX.JS
require("dotenv").config();
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const fs = require('fs');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});

client.commands = new Collection();
client.aliases = new Collection();

const prefix = ".";

// Manejador de comandos
fs.readdirSync('./commands').forEach(module => {
const commandFiles = fs.readdirSync(`./commands/${module}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${module}/${file}`);
console.log(`[CMD] ${command.name} El comando ha sido cargado - ✅`);
client.commands.set(command.name, command);
if (command.aliases) {
command.aliases.forEach(alias => client.aliases.set(alias, command.name));
}
}
});

// Evento cuando el bot está listo
client.once('ready', () => {
console.log(`Bot listo como ${client.user.tag} - ✅`);
});

// Evento de mensaje
client.on('messageCreate', message => {
if (message.author.bot) return; // Ignorar mensajes de otros bots
if (!message.content.startsWith(prefix)) return; // Ignorar mensajes sin el prefijo

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

const command = client.commands.get(commandName) || client.commands.get(client.aliases.get(commandName));

if (!command) return;

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Hubo un error al ejecutar el comando.').catch(console.error);
}
});

// Inicializando el proyecto
const token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxU';
client.login(token);
require("dotenv").config();
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const fs = require('fs');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});

client.commands = new Collection();
client.aliases = new Collection();

const prefix = ".";

// Manejador de comandos
fs.readdirSync('./commands').forEach(module => {
const commandFiles = fs.readdirSync(`./commands/${module}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${module}/${file}`);
console.log(`[CMD] ${command.name} El comando ha sido cargado - ✅`);
client.commands.set(command.name, command);
if (command.aliases) {
command.aliases.forEach(alias => client.aliases.set(alias, command.name));
}
}
});

// Evento cuando el bot está listo
client.once('ready', () => {
console.log(`Bot listo como ${client.user.tag} - ✅`);
});

// Evento de mensaje
client.on('messageCreate', message => {
if (message.author.bot) return; // Ignorar mensajes de otros bots
if (!message.content.startsWith(prefix)) return; // Ignorar mensajes sin el prefijo

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

const command = client.commands.get(commandName) || client.commands.get(client.aliases.get(commandName));

if (!command) return;

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Hubo un error al ejecutar el comando.').catch(console.error);
}
});

// Inicializando el proyecto
const token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxU';
client.login(token);
EXP OF MY COMMAND
const { MessageEmbed } = require('discord.js');
const { Color } = require('../../config.js');
const { promisify } = require('util');
const figlet = require('figlet');

const figletAsync = promisify(figlet);

module.exports = {
data: {
name: 'ascii',
aliases: [],
description: 'Ascii Art!',
usage: 'Ascii <Text>',
},
execute: async (interaction) => {
// Start
const Content = interaction.options.getString('text');

if (!Content) {
return interaction.reply({ content: '**¡Por favor! Ponme texto que no supere 20 argumentos.**', ephemeral: true });
}

if (Content.length > 20) {
return interaction.reply({ content: '**¡Por favor, hazlo más corto! | Límite: 20**', ephemeral: true });
}

const Result = await figletAsync(Content);

const embed = new MessageEmbed()
.setColor(Color)
.setDescription('
const { MessageEmbed } = require('discord.js');
const { Color } = require('../../config.js');
const { promisify } = require('util');
const figlet = require('figlet');

const figletAsync = promisify(figlet);

module.exports = {
data: {
name: 'ascii',
aliases: [],
description: 'Ascii Art!',
usage: 'Ascii <Text>',
},
execute: async (interaction) => {
// Start
const Content = interaction.options.getString('text');

if (!Content) {
return interaction.reply({ content: '**¡Por favor! Ponme texto que no supere 20 argumentos.**', ephemeral: true });
}

if (Content.length > 20) {
return interaction.reply({ content: '**¡Por favor, hazlo más corto! | Límite: 20**', ephemeral: true });
}

const Result = await figletAsync(Content);

const embed = new MessageEmbed()
.setColor(Color)
.setDescription('
' + Result + '
')
.setTimestamp();

interaction.reply({ embeds: [embed] });
// End
},
};
')
.setTimestamp();

interaction.reply({ embeds: [embed] });
// End
},
};
Harnes
Harnes10mo ago
Show your project structure
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
What project???
Harnes
Harnes10mo ago
Project folder structure
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
And where is that (I'm a bit of a noob)
Harnes
Harnes10mo ago
I think I found your problem In some commands you are exporting data property that contains name and other properties
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
yeeeeee, let's see
Harnes
Harnes10mo ago
But in your command handler you're setting command's name from directly command object which does not exist
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
And how to fix that?
Harnes
Harnes10mo ago
... data: { name: '...' ...
... client.commands.set(command.name) ...
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
in my handlre??
Harnes
Harnes10mo ago
property name does not exist on command object also looks like you are using both Use one
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
I don't understand why I should apply that to my handler?
Harnes
Harnes10mo ago
If you don't understand what I said then you need to brush your JS skills #rules 3
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
Do I apply this to my handler??? Srry for ping
Harnes
Harnes10mo ago
This is an example from your code Also as I said higher you are mixing both, in some commands you are exporting name property that your handler uses and in some you are exporting data object with name property
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
That index.js is from an AI since I don't know how to do index.js
Harnes
Harnes10mo ago
#rules 3
Andres.ᵈᵉᵛ
Andres.ᵈᵉᵛOP10mo ago
I don't understand that rule, I read it 40 times, I remind you that I am Spanish.
Mufaro
Mufaro10mo ago
Then your bio is basically a huge lie.
Bloonatics
Bloonatics10mo ago
about me looks familiar :meguFace:
chewie
chewie10mo ago
Please brush up on your javascript knowledge, which you seem to be lacking completely. Don't use AI to write code for you. #rules 3 #resources
Want results from more Discord servers?
Add your server