'MessageEmbed' is declared but its value is never read.

I have no idea why this has happened, its my first encounter with this error.
No description
No description
47 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
muffin.
muffin.9mo ago
async function checkEarthquakes() {
try {
const response = await axios.get('https://api.orhanaydogdu.com.tr/deprem/live.php?limit=1');
const earthquakeData = response.data.result[0];

if (earthquakeData) {
const embed = new Discord.MessageEmbed()
.setColor("0xff5733")
.setTitle('Earthquake in Turkey')
.addFields(
{ name: 'Magnitude', value: earthquakeData.mag, inline: true },
{ name: 'City', value: earthquakeData.city, inline: true },
{ name: 'District', value: earthquakeData.dist, inline: true }
)
.setTimestamp();

const guild = await client.guilds.fetch('1130895523088437249');
const channel = guild.channels.cache.get('1188055850800123975');

if (channel) {
channel.send({ embeds: [embed] });
} else {
console.error('Channel not found. Please check your channel ID.');
}
}
} catch (error) {
console.error('Error fetching earthquake data:', error);
}
}
async function checkEarthquakes() {
try {
const response = await axios.get('https://api.orhanaydogdu.com.tr/deprem/live.php?limit=1');
const earthquakeData = response.data.result[0];

if (earthquakeData) {
const embed = new Discord.MessageEmbed()
.setColor("0xff5733")
.setTitle('Earthquake in Turkey')
.addFields(
{ name: 'Magnitude', value: earthquakeData.mag, inline: true },
{ name: 'City', value: earthquakeData.city, inline: true },
{ name: 'District', value: earthquakeData.dist, inline: true }
)
.setTimestamp();

const guild = await client.guilds.fetch('1130895523088437249');
const channel = guild.channels.cache.get('1188055850800123975');

if (channel) {
channel.send({ embeds: [embed] });
} else {
console.error('Channel not found. Please check your channel ID.');
}
}
} catch (error) {
console.error('Error fetching earthquake data:', error);
}
}
const Discord = require("discord.js");
const { MessageEmbed } = require('discord.js');
const axios = require('axios');

const mySecret = process.env['token'];
const { Intents } = require("discord.js");
const Discord = require("discord.js");
const { MessageEmbed } = require('discord.js');
const axios = require('axios');

const mySecret = process.env['token'];
const { Intents } = require("discord.js");
Yes, this code is above the other one.
Error fetching earthquake data: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
at Util.verifyString (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/util/Util.js:507:41)
at MessageEmbed.normalizeField (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:555:19)
at /home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:576:14
at Array.map (<anonymous>)
at MessageEmbed.normalizeFields (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:575:8)
at MessageEmbed.addFields (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:339:42)
at checkEarthquakes (/home/runner/Chrimate-Observatory/index.js:50:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[Symbol(code)]: 'EMBED_FIELD_VALUE'
}
Error fetching earthquake data: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
at Util.verifyString (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/util/Util.js:507:41)
at MessageEmbed.normalizeField (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:555:19)
at /home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:576:14
at Array.map (<anonymous>)
at MessageEmbed.normalizeFields (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:575:8)
at MessageEmbed.addFields (/home/runner/Chrimate-Observatory/node_modules/discord.js/src/structures/MessageEmbed.js:339:42)
at checkEarthquakes (/home/runner/Chrimate-Observatory/index.js:50:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[Symbol(code)]: 'EMBED_FIELD_VALUE'
}
full stack error.
jay
jay9mo ago
im wondering why you have 3 imports to discord.js nevertheless this means your field values hasnt got any data
treble/luna
treble/luna9mo ago
also, the warning that you get is because you deconstruct MessageEmbed but you never call it You call Discord.MessageEmbed
muffin.
muffin.9mo ago
because of this
No description
treble/luna
treble/luna9mo ago
you indeed never use it
jay
jay9mo ago
instead you’re using Discord.MessageEmbed
muffin.
muffin.9mo ago
when I remove it its the same error though
treble/luna
treble/luna9mo ago
as you're told, why do you have 3 imports Either destructure or dont, but not both
muffin.
muffin.9mo ago
When I delete the imports it gives the same error
treble/luna
treble/luna9mo ago
. so pick what you want
muffin.
muffin.9mo ago
How do I desturcture it exactly
d.js docs
d.js docs9mo ago
mdn Destructuring assignment The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
treble/luna
treble/luna9mo ago
Pretty basic js
muffin.
muffin.9mo ago
Okay but why do I need to destructure if I just delete the imports and dont use them?
Want results from more Discord servers?
Add your server