2
const { Client, GatewayIntentBits, Partials } = require('discord.js')
const {token} = require("../config.json")

const client = new Client({
  'intents': [
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildBans,
    GatewayIntentBits.GuildMessages,
  ],
  'partials': [Partials.Channel]
});

client.on('messageCreate', (message) => {
    console.log(message.content)
});

client.login(token)

Bot Permissions

Permission page screenshot

Problem

I've been researching the issue for 1-2 weeks but couldn't find a solution. My problem is that message.content is empty. There were several places on the Discord developer portal suggesting that I allow it, but I still always get a blank result.

I want to receive any message that users send to channels so I am using this code.

  • have you checked this link https://stackoverflow.com/questions/73036854/message-content-doesnt-have-any-value-in-discord-js – inkredusk Apr 15 '23 at 12:50

1 Answers1

0

In the Discord developer portal, make sure you enable the intent for viewing the contents of messages, and make sure you specify that intent when creating the client.

Example Image