How is it possible that the Message's author is equivalent to null?

TypeError: Cannot read properties of null (reading 'id')
at Object.execute (D:\bot\dist\events\messageDelete.js:12:28)
at DiscordClient.<anonymous> (D:\bot\dist\handlers\events.js:43:54)
at DiscordClient.emit (node:events:513:28)
at MessageDeleteAction.handle (D:\bot\node_modules\discord.js\src\client\actions\MessageDelete.js:24:16)
TypeError: Cannot read properties of null (reading 'id')
at Object.execute (D:\bot\dist\events\messageDelete.js:12:28)
at DiscordClient.<anonymous> (D:\bot\dist\handlers\events.js:43:54)
at DiscordClient.emit (node:events:513:28)
at MessageDeleteAction.handle (D:\bot\node_modules\discord.js\src\client\actions\MessageDelete.js:24:16)
Error reffers to
const discord_js_1 = require("discord.js");
const EmbedBuilder_1 = __importDefault(require("../structures/overwrite/EmbedBuilder"));
const event = {
name: discord_js_1.Events.MessageDelete,
once: false,
async execute(client, message) {
if (message.author.id == client.user.id) return;
^
const discord_js_1 = require("discord.js");
const EmbedBuilder_1 = __importDefault(require("../structures/overwrite/EmbedBuilder"));
const event = {
name: discord_js_1.Events.MessageDelete,
once: false,
async execute(client, message) {
if (message.author.id == client.user.id) return;
^
Generated from
const event: BaseEvent = {
name: Events.MessageDelete,
once: false,
async execute(client: Client, message: Message) {
if (message.author.id == client.user.id) return;
const event: BaseEvent = {
name: Events.MessageDelete,
once: false,
async execute(client: Client, message: Message) {
if (message.author.id == client.user.id) return;
6 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Squid
Squid2y ago
Message#author is nullable since deleted messages are often partials, so you can't access all of their properties
fenya
fenyaOP2y ago
Ok, thx. In this case we need doc's & Message type update
Squid
Squid2y ago
What specific DJS version are you using? The docs say it's ?User
fenya
fenyaOP2y ago
Ok, the docs say its ?User. I didn't notice that
Parogo_72
Parogo_722y ago
use PartialMessage type instead, there has just been a similar question in #djs-help-v14 If you dont enable Message partial, it will always be a Message instance
Want results from more Discord servers?
Add your server