#reply

1 messages · Page 1 of 1 (latest)

vapid wagon
#

should I set message.reference as a variable?

#

@river solstice

river solstice
#

Wont change anything, has the same value

vapid wagon
#

ok, check the code

vapid wagon
river solstice
#

Finna get a cannot read property id of null

#

Dont use var, theres a whole site explaining why

#

And sure

#

Finna have same value

vapid wagon
#

but the value is saying null even though the client replies to someone

river solstice
#

Show

vapid wagon
#
F:\Discord bot packages\Test_bot\node_modules\discord.js\src\util\Util.js:413
    if (typeof data !== 'string') throw new error(errorMessage);
                                        ^

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
    at Function.verifyString (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\util\Util.js:413:41)
    at Function.normalizeField (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessageEmbed.js:443:19)       
    at F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessageEmbed.js:464:14
    at Array.map (<anonymous>)
    at Function.normalizeFields (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessageEmbed.js:463:8)       
    at MessageEmbed.setup (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessageEmbed.js:103:91)
    at new MessageEmbed (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessageEmbed.js:41:10)
    at F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessagePayload.js:184:49
    at Array.map (<anonymous>)
    at MessagePayload.resolveData (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\MessagePayload.js:184:36) {
  [Symbol(code)]: 'EMBED_FIELD_VALUE'
}
#

and I have made a dummy server just for testing the bot

#

I replied to my own message and it says null

river solstice
#

One of ur embed field's value is not a string or is an empty string

vapid wagon
#
PS F:\Discord bot packages\Test_bot> node index.js
Ready!
{
  error: TypeError: Cannot read property 'id' of null
      at Client.<anonymous> (F:\Discord bot packages\Test_bot\interactions\messageCreate.js:19:42)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
}
vapid wagon
#

message.reference is appearing as null type

#

@river solstice

river solstice
river solstice
#

Well the message you have, whatever message is defined as, that message is not replying to a message so message.reference is null

river solstice
#

Wdym?

vapid wagon
#

are these messages cached?

#

then why is that error popping then?

river solstice
#

What messages? I believe all messages are cached

river solstice
vapid wagon
# river solstice The message you have is not replying to a message

Can you check my full code?

const { server_log } = require('.//../channel.json');
const { makeEmbed } = require('.//../embed');
module.exports = (client) => {
    client.on("messageCreate", async (message) => {
    
        try 
        {
           if (message.author.bot) return;
           const avatar = message.author.displayAvatarURL({ dynamic: true })
           const username = `${message.author.tag}`
           const link = message.url
           const usertag = `<@${message.author.id}>`
           const sentchannel = `<#${message.channelId}>`
           const channel = await client.channels.fetch(server_log);
           var urls = message.attachments.map(x => x.url).join("\n") ;
           var reply = message.reference.id;
           if (urls == '') urls = 'None'

           const exampleEmbed = {
            color: 0x0099ff,
            title: 'Message Creation: ',
            url: link,
            author: {
                name: username,
                icon_url: avatar,
                url: avatar,
            },
            description: message.content,
            thumbnail: {
                url: avatar,
            },
            
#
fields: [
                {
                    name: 'Attachments:',
                    value: urls,
                },
                {
                    name: '\u200b',
                    value: '\u200b',
                    inline: false,
                },
                {
                    name: 'Sent Channel:',
                    value: sentchannel,
                    inline: true,
                },
                {
                    name: 'Message Link:',
                    value: link,
                    inline: true,
                },
                {
                    name: 'Reply',
                    value: 'reply',
                    inline: true,
                },
            ],
            image: {
                url: 'https://i.imgur.com/AfFp7pu.png',
            },
            timestamp: new Date(),
            footer: {
                text: 'Some footer text here',
                icon_url: 'https://i.imgur.com/AfFp7pu.png',
            },
        };
        
        channel.send({ embeds: [exampleEmbed] }); 
} 
        catch (error) 
        {
            console.error({error});
        }
    
      });
    }
river solstice
#

reply or message.reference will be null if the message is not replying to a message

#

Idk how to tell u that again

#

Check if its null

const reply = message.reference?.id;
if(!reply) return message.channel.send('There was no reply for this message so I didn\'t get the ID');
vapid wagon
#

that shows null too

#

and it wasn't supposed to be

river solstice
#
const reply = (await message.fetchReference().catch(() => {})).id;
if(!reply) return message.reply('this message is not replying to a message');
#

Both ways work

vapid wagon
#

ok, now it didn't sent that message in the channel

#

so it detected the reply then

#

@river solstice BTW, why this error is showing?

{
  error: Error [MESSAGE_REFERENCE_MISSING]: The message does not reference another message
      at Message.fetchReference (F:\Discord bot packages\Test_bot\node_modules\discord.js\src\structures\Message.js:577:32)
      at Client.<anonymous> (F:\Discord bot packages\Test_bot\interactions\messageCreate.js:19:41)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    [Symbol(code)]: 'MESSAGE_REFERENCE_MISSING'
  }
}```
river solstice
#

Well, cuz the message is not replying to a message

#

Im editing the ezample Inposted

vapid wagon
#

there's also another issue here

#

@river solstice

#

if the message is not a reply