Bot not responding to prefix cmds

Hi to all! I have the following in my ./events/messageCreate.js
const { Events } = require('discord.js');
module.exports = {
name: Events.MessageCreate,

execute(message) {
const prefix = "+";
console.log(")")
if (!message.content.startsWith(prefix) || message.author.bot) return;

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

const command = message.client.commands.get(commandName) || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
console.log("o")
if (!command) return;

// Check permissions, cooldowns, etc.

try {

command.execute(message, args);

} catch (error) {

console.error(error);

message.reply('There was an error trying to execute that command!');

}
},
};
const { Events } = require('discord.js');
module.exports = {
name: Events.MessageCreate,

execute(message) {
const prefix = "+";
console.log(")")
if (!message.content.startsWith(prefix) || message.author.bot) return;

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

const command = message.client.commands.get(commandName) || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
console.log("o")
if (!command) return;

// Check permissions, cooldowns, etc.

try {

command.execute(message, args);

} catch (error) {

console.error(error);

message.reply('There was an error trying to execute that command!');

}
},
};
The bot isn't responding when I do +ping I will attach my ping.js below as msg
2 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 OP
NanotechPikachu
NanotechPikachuOP10mo ago
The code in ./commands/prefix-cmds/utility/ping.js
module.exports = {
name: 'ping',
description: 'Pings the bot and shows the latency.',
aliases: ['pong'],
execute(message, args) {
console.log("#")
const timeTaken = Date.now() - message.createdTimestamp;
message.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
}
};
module.exports = {
name: 'ping',
description: 'Pings the bot and shows the latency.',
aliases: ['pong'],
execute(message, args) {
console.log("#")
const timeTaken = Date.now() - message.createdTimestamp;
message.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
}
};
The index.js for prefix handle
const prefixCommandFolders = fs.readdirSync('./commands/prefix-cmds');

for (const folder of prefixCommandFolders) {
console.log("@")
const commandFiles = fs.readdirSync(`./commands/prefix-cmds/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/prefix-cmds/${folder}/${file}`);
client.commands.set(command.name, command);
}
}
const prefixCommandFolders = fs.readdirSync('./commands/prefix-cmds');

for (const folder of prefixCommandFolders) {
console.log("@")
const commandFiles = fs.readdirSync(`./commands/prefix-cmds/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/prefix-cmds/${folder}/${file}`);
client.commands.set(command.name, command);
}
}
I would be thankful for ur help Nvm i got it. It was an intent issue
Want results from more Discord servers?
Add your server