Home > Net >  Empty embeds array in message object - Discord.js 14
Empty embeds array in message object - Discord.js 14

Time:08-03

I just switched to discord.js 14 and i'm trying to read the content of an embed sent by the disboard bot. When i console.log the message, i see the following:

<ref *1> Message {
  channelId: '1003514350461530163',
  guildId: '1001162424969330698',
  id: '1004028156040188015',
  createdTimestamp: 1659449366341,
  type: 20,
  system: false,
  content: '',
  author: User {
    id: '302050872383242240',
    bot: true,
    system: false,
    flags: UserFlagsBitField { bitfield: 589824 },
    username: 'DISBOARD',
    discriminator: '2760',
    avatar: '67342a774a9f2d20d62bfc8553bb98e0',
    banner: undefined,
    accentColor: undefined
  },
  pinned: false,
  tts: false,
  nonce: '1004028150490857472',
  embeds: [],
  components: [],
  attachments: Collection(0) [Map] {},
  stickers: Collection(0) [Map] {},
  editedTimestamp: null,
  reactions: ReactionManager { message: [Circular *1] },  
  mentions: MessageMentions {
    everyone: false,
    users: Collection(0) [Map] {},
    roles: Collection(0) [Map] {},
    _members: null,
    _channels: null,
    _parsedUsers: null,
    crosspostedChannels: Collection(0) [Map] {},
    repliedUser: null
  },
  webhookId: '302050872383242240',
  groupActivityApplication: null,
  applicationId: '302050872383242240',
  activity: null,
  flags: MessageFlagsBitField { bitfield: 0 },
  reference: null,
  interaction: {
    id: '1004028155260047411',
    type: 2,
    commandName: 'page',
    user: User {
      id: '995903736096489504',
      bot: false,
      system: false,
      flags: [UserFlagsBitField],
      username: 'Babylonia Angelis',
      discriminator: '7643',
      avatar: 'fe805d55b1d1e4e18281b2b3560e0e37',
      banner: undefined,
      accentColor: undefined
    }
  }
}

enter image description here

Why is the embeds array empty? I googled it but dosnt seem to find anything on that. thank ya.

EDIT

This is how i fetch the message as asked.

// Require the necessary discord.js classes
const { Client, GatewayIntentBits, IntentsBitField } = require('discord.js');
const { token } = require('./config.json');

const myIntents = new IntentsBitField();
myIntents.add(IntentsBitField.Flags.GuildPresences,IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.GuildMembers,GatewayIntentBits.Guilds);

// Create a new client instance
const client = new Client({ intents: myIntents});

// When the client is ready, run this code (only once)
client.once('ready', () => {
    console.log('ready')
});

client.on("messageCreate", message => {
    console.log(message)
    return
})

// Login to Discord with your client's token
client.login(token);

Thank you:)

CodePudding user response:

You don't receive certain fields because you're missing the MESSAGE_CONTENT intent.

const myIntents = new IntentsBitField();
myIntents.add(
IntentsBitField.Flags.GuildPresences, IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMembers,GatewayIntentBits.Guilds,
IntentsBitFiled.Flags.MessageContent
);

Also, make sure that you have the MESSAGE_CONTENT privilege enabled at: https://discord.com/developers/applications

Picture for reference: https://i.imgur.com/mi8XMZb.jpg

  • Related