#reply
1 messages · Page 1 of 1 (latest)
Ur choice
Wont change anything, has the same value
ok, check the code
var reply = message.reference.id;
Finna get a cannot read property id of null
Dont use var, theres a whole site explaining why
And sure
Finna have same value
but the value is saying null even though the client replies to someone
Show
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
One of ur embed field's value is not a string or is an empty string
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)
}
and the 19th line is that
message.reference is appearing as null type
@river solstice
Then the bot's message is not replying to another message, I told u you'd get tht error
bot's message?
Well the message you have, whatever message is defined as, that message is not replying to a message so message.reference is null
BTW, are they cached?
Wdym?
What messages? I believe all messages are cached
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});
}
});
}
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');
that shows null too
and it wasn't supposed to be
const reply = (await message.fetchReference().catch(() => {})).id;
if(!reply) return message.reply('this message is not replying to a message');
Both ways work
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'
}
}```