Bot doesn't reply, DJS v14

Index.js
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits, Partials } = require('discord.js');
const { token } = require('./config.json'); const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages],
partials: [Partials.Channel]
});
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits, Partials } = require('discord.js');
const { token } = require('./config.json'); const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages],
partials: [Partials.Channel]
});
the console.log works but the bot doesn't reply. Message handling.
module.exports = {
name: 'messageCreate',
execute(message) {
console.log(`Received a message from ${message.author.tag}: ${message.content}`);

if (message.author.bot) return;

if (message.channel.type === 'dm' && message.content === '!hi') {
message.author.send('Hello!');
}
},
};
module.exports = {
name: 'messageCreate',
execute(message) {
console.log(`Received a message from ${message.author.tag}: ${message.content}`);

if (message.author.bot) return;

if (message.channel.type === 'dm' && message.content === '!hi') {
message.author.send('Hello!');
}
},
};
12 Replies
d.js toolkit
d.js toolkit7mo 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
samp
samp7mo ago
are you testing with a dm channel?
Zaenalos
Zaenalos7mo ago
Yes sir
samp
samp7mo ago
also, do you have message content intent?
No description
samp
samp7mo ago
in the discord developer portal
Zaenalos
Zaenalos7mo ago
I tried to dm the bot, the console.log returns good result but the bot doesn't reply. Okay wait Yes sir
Zaenalos
Zaenalos7mo ago
No description
Zaenalos
Zaenalos7mo ago
It does
samp
samp7mo ago
are you sure message.author.send('Hello!'); is correct? maybe it should be message.channel.send('Hello!'); i don't know, I program with slash commands I don't know much about text cmds
Zaenalos
Zaenalos7mo ago
Doesn't work either sir Its okay! Thank you for helping tho Thank you for helping, i 've already fixed the issue. It should be
message.channel.type === 1
message.channel.type === 1
and not
message.channel.type === 'dm'
message.channel.type === 'dm'
samp
samp7mo ago
ah that was a cheeky one
Zaenalos
Zaenalos7mo ago
True I debugged the message into json format so i can take a better look. Thank you for suggestion