#Embeds issue

1 messages · Page 1 of 1 (latest)

turbid trench
#

..

#
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
    at Function.verifyString (C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\util\Util.js:417:49)
    at Function.normalizeField (C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\structures\MessageEmbed.js:544:19)
    at C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\structures\MessageEmbed.js:565:14
    at Array.map (<anonymous>)
    at Function.normalizeFields (C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\structures\MessageEmbed.js:564:8)
    at MessageEmbed.addFields (C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\structures\MessageEmbed.js:328:42)
    at Client.<anonymous> (C:\Users\Administrator\Desktop\Sabersunknown\events\messageUpdate.js:10:7)
    at Client.emit (node:events:390:28)
    at Object.module.exports [as MESSAGE_UPDATE] (C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_UPDATE.js:14:12)
    at WebSocketManager.handlePacket (C:\Users\Administrator\Desktop\Sabersunknown\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31) {
  [Symbol(code)]: 'EMBED_FIELD_VALUE'
}
mystic widget
#

The error is in your messageUpdate file, not the purge file

turbid trench
mystic widget
turbid trench
#

Can you elaborate? Its early afternoon and I haven't woke up

mystic widget
#

Do you know what partials are? And maybe come back when you‘re awake

turbid trench
# mystic widget Do you know what partials are? And maybe come back when you‘re awake

Okay, Yep. Took me a minute.. I don't use partials I use intents.

const { Client, Collection } = require("discord.js");
require('dotenv').config();
const client = new Client({
    intents: 32767,
});
module.exports = client;

// Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.config = process.env

// Initializing the project
require("./handler")(client);

client.login(client.config.token);
mystic widget
#

In that Case the Message wasn’t fully cached and the oldMesssage content is empty

analog schooner
#

I thought we skip events with partial data unless partials are enabled?

turbid trench
analog schooner
#

Or use partials

inner tigerBOT
turbid trench
#

I'm not recoding half my index, i'll just slap a check in there

analog schooner
#

wdym recoding half your index, you just have to enable them in the client constructor and then fetch the old message if its partial

turbid trench
#

It took me a minute to figure out that I only needed to do that

#

:/

turbid trench
turbid trench
#

I don't know how to check partials though, I've never used them

weary light
# turbid trench yes

one of the fields value is empty, as in it cannot get the string value because it is null or empty, I think.

weary light
turbid trench
#

Okay, how do I make it so that it returns "Couldn't get message" instead of crashing?

weary light
#

module.exports = async function(client) {
const {MessageEmbed} = require('discord.js');
client.on('messageUpdate', async(oldMessage, newMessage) => { // Old message may be undefined
if (!oldMessage.author) return;
const MessageLog = client.channels.cache.get('982333334065643551');
if (!oldMessage) return MessageLog.send("Failed to get message.")
var embed = new MessageEmbed()
.setTitle('Message Edited!')
.setTimestamp()
.setColor("YELLOW")
.addFields(
{name: "Author:", value: <@${newMessage.author.id}> [\${newMessage.author.tag}`]}, {name: "Author ID:", value: ${newMessage.author.id}}, {name: 'Old Message:',value: ${oldMessage}}, {name: 'Edited Message::', value: ${newMessage}}, {name: "Channel:", value: <#${newMessage.channel.id}>`}
);
await MessageLog.send({embeds: [embed]});
});
}

#

look at the bold parts

turbid trench
analog schooner
#

oldMessage ?? 'Old message not found'

or something like that

#

you should make sure it even is that problem and not something else

turbid trench
#

thats what I'm trying to figure out. this is messing with my mind

analog schooner
#

kindly not spoonfeed shit

#

thanks

weary light
#

wtf

turbid trench
analog schooner
#

oldMessage ?? 'Old message not found'
newMessage ?? 'New message not found'

#

assuming everything else is defined

weary light
#

i was gonna do

analog schooner
#

dont care what you gonna do

#

spoonfeeding is against the rules

weary light
#

if(oldMessage){
embed part: ${oldMessage}
}else if(!oldMessage{
embed part: 'Couldnt get old message.'
}

#

happy?

analog schooner
#

No

weary light
#

why

analog schooner
#

now kindly stop

weary light
#

ok

#

what did i do wrong

analog schooner
turbid trench
#

Thanks hairy

analog schooner
#

did it work?

turbid trench
#

did what? sorry, I'm multitasking rn. I have people messaging me on snap and I am getting a lot of phone calls

#

😂

analog schooner
turbid trench
#

Aight, I'll try it

turbid trench
#

I don't think thats the error, Its only showing when I run the purge command.

analog schooner
#

wait

#

purge as in yeeting messages

turbid trench
#

yes

analog schooner
#

why does your stack trace above show messageUpdate tho

#

deleting a message shouldnt trigger that

turbid trench
#

I couldn't tell you man.

analog schooner
#

do you have a message delete event handler

turbid trench
#

I mean, I could screenshare in a VC and show you some of the problems if you want

turbid trench
analog schooner
#

show that one

turbid trench
#
module.exports = async function(client) {
    const { MessageEmbed } = require('discord.js');

    client.on("messageDelete", async (message) => {
        const logchannel = client.channels.cache.get('982333334065643551');

        if(message.author.bot) return;
        const filteredcontent = message.content.substring(0, 25);
        const newembed = new MessageEmbed({
            color: "DARK_RED",
            title: "Message Deleted!"
        }).setFields(
            {name: "Author:", value: `<@${message.author.id}> [\`${message.author.tag}\`]`},
            {name: "Author ID:", value: `${message.author.id}`},
            {name: "Message Content:", value: `${filteredcontent}`},
            {name: "Channel:", value: `<#${message.channel.id}>`}
        );

       await logchannel.send({embeds: [newembed]});
    });
}
analog schooner
#

filteredcontent is the problem then most likely

#

there is no content if the message wasnt cached

turbid trench
#

Okay, how do I fix it without losing the limit?

analog schooner
#

one sec

#

filteredcontent || 'Content not available'

#

you cant use ?? cuz substring on an empty string returns an empty string

#

which isnt null nor undefined

turbid trench
#

Alright, lemme try that

analog schooner
#

will move you then