Skip to content

Issues with message.author randomly returning undefined #10166

@The-Lord-of-Owls

Description

@The-Lord-of-Owls

Which package is this bug report for?

discord.js

Issue description

During the MessageDelete event message.author is for what ever reason coming back undefined and it makes no sense why a message would have no author for some, but other deleted messages still have it. It seems to be related to when the bot starts and when the message is originally sent.

Steps to reproduce:

  1. Send a message
  2. Start the bot
  3. Delete the message
  4. Code inside the MessageDelete event logs to the console the message object.author
  5. Results in undefined

I see no reason why this should be happening with messages sent prior to the bot being started.

Code sample

const { TOKEN, APP_ID } = process.env
const {	Client, Events, GatewayIntentBits, Partials } = require( 'discord.js' )

const client = new Client({
	intents: [ GatewayIntentBits.Guilds,GatewayIntentBits.GuildBans,GatewayIntentBits.GuildMessages,GatewayIntentBits.GuildMessageReactions,GatewayIntentBits.MessageContent ],
	partials: [ Partials.User,Partials.Channel,Partials.Reaction,Partials.Message,Partials.GuildMember ]
})

client.on( Events.MessageDelete, async ( message ) => {
	console.log( message )
	console.log( message.author )
} )

client.login( TOKEN )

Versions

Version of discord.js: discord.js@14.14.1

Issue priority

Low (slightly annoying)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction

Which gateway intents are you subscribing to?

Guilds, GuildMessages, GuildMessageReactions, MessageContent

I have tested this issue on a development release

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions