#Bot doesn't reply, DJS v14

23 messages · Page 1 of 1 (latest)

tender vector
#

Index.js

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!');
    }
  },
};```
hearty berryBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
tender vector
#

Yes sir

#

also, do you have message content intent?

#

in the discord developer portal

#

I tried to dm the bot, the console.log returns good result but the bot doesn't reply.

#

Okay wait

#

Yes sir

#

It does

#

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

#

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
and not
message.channel.type === 'dm'

tender vector
#

that was a cheeky one

#

True

#

I debugged the message into json format so i can take a better look.

grave timber