embed
Error pinging the nodes: TypeError: MessageEmbed is not a constructor
at Object.execute (/home/container/commands/server/nodepinger.js:23:31)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.jjs4)
72 Replies
- 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!bump
s
it's
EmbedBuilder
for v14ty let me try
Error pinging the nodes: ReferenceError: MessageEmbed is not defined
at Object.execute (/home/container/commands/server/nodepinger.js:23:31)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4)
new error
you didn't change it
you forgot to change it on your interactionCreate event
where
^
:i dont understand
wher
e
go to your interactionCreate.js file and change MessageEmbed to EmbedBuilder
ok
const { Events } = require('discord.js');
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(
No command matching ${interaction.commandName} was found.
);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
},
};
where
@-Carlosπis that your full code
yes
can you run
npm list discord.js
on your console
wait, did you save the fileyes
are you sure
yes
@-Carlosπ
did you also change it on the
const embed = new MessageEmbed()
part?
also can you stop pinging mewhat am i gonna change it to
const embed = new MessageEmbed()
^
ok
const embed = new EmbedBuilder ()
to that
yeah
remove that extra space
ok
Error pinging the nodes: TypeError [ColorConvert]: Unable to convert color to a number.
at resolveColor (/home/container/node_modules/discord.js/src/util/Util.js:290:63)
at EmbedBuilder.setColor (/home/container/node_modules/discord.js/src/structures/EmbedBuilder.js:23:36)
at Object.execute (/home/container/commands/server/nodepinger.js:26:22)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4) {
code: 'ColorConvert'
}
embed colors are PascalCase
do this
#57F287
yeah if you want to use a hex color instead that should work
Error pinging the nodes: DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/container/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/BurstHandler.ts:143:20)
at async _REST.request (/home/container/node_modules/@discordjs/rest/src/lib/REST.ts:211:20)
at async ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
at async Object.execute (/home/container/commands/server/nodepinger.js:32:17)
at async Object.execute (/home/container/events/interactionCreate.js:16:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1218733265435758622/aW50ZXJhY3Rpb246MTIxODczMzI2NTQzNTc1ODYyMjozbDJ1WGxnMWRHaUQxU1p6MHIyUFRqVTR5Z0ZwVnhLbGRYcGJRQU5kQlVQYjk1UXc5SzVndjBJd3NIUHY2WU83TjJMeGhVVUt1YkN5SEJaVzk3U3hreGk3M0QyamhsOEtMUGU0UWlCRlU0RW9sOHVqZUZobVV4NW1ZckNyN09UWg/callback'
}
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/container/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/BurstHandler.ts:143:20)
at async _REST.request (/home/container/node_modules/@discordjs/rest/src/lib/REST.ts:211:20)
at async ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
at async Object.execute (/home/container/commands/server/nodepinger.js:38:13)
at async Object.execute (/home/container/events/interactionCreate.js:16:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1218733265435758622/aW50ZXJhY3Rpb246MTIxODczMzI2NTQzNTc1ODYyMjozbDJ1WGxnMWRHaUQxU1p6MHIyUFRqVTR5Z0ZwVnhLbGRYcGJRQU5kQlVQYjk1UXc5SzVndjBJd3NIUHY2WU83TjJMeGhVVUt1YkN5SEJaVzk3U3hreGk3M0QyamhsOEtMUGU0UWlCRlU0RW9sOHVqZUZobVV4NW1ZckNyN09UWg/callback'
}
/home/container/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148
throw new DiscordAPIError(data, 'code' in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/container/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/BurstHandler.ts:143:20)
at async _REST.request (/home/container/node_modules/@discordjs/rest/src/lib/REST.ts:211:20)
at async ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
at async Object.execute (/home/container/events/interactionCreate.js:22:5) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1218733265435758622/aW50ZXJhY3Rpb246MTIxODczMzI2NTQzNTc1ODYyMjozbDJ1WGxnMWRHaUQxU1p6MHIyUFRqVTR5Z0ZwVnhLbGRYcGJRQU5kQlVQYjk1UXc5SzVndjBJd3NIUHY2WU83TjJMeGhVVUt1YkN5SEJaVzk3U3hreGk3M0QyamhsOEtMUGU0UWlCRlU0RW9sOHVqZUZobVV4NW1ZckNyN09UWg/callback'
}
show your full code
full code, not full error
ok
umm u there
yeah
Common causes of
DiscordAPIError[10062]: Unknown interaction
:
- Initial response took more than 3 seconds β defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responsesmost likely that axios call took more than 3 seconds
how to fix
it says it here
dont understand
- Initial response took more than 3 seconds β defer the response *.
how do i fix
async execute(interaction) {
try {
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer your-api-key',
'Content-Type': 'application/json'
}
});
like this
nvm
can u fix it for me
@-Carlosπ
you literally just need to defer the reply
async execute(interaction) {
try {
await interaction.deferReply();
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer your-api-key',
'Content-Type': 'application/json'
}
});
like this
yeah, but don't use ChatGPT
ok
i did not kown
sorry
Error pinging the nodes: Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at Object.execute (/home/container/commands/server/nodepinger.js:36:27)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4) {
code: 'InteractionAlreadyReplied'
}
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at Object.execute (/home/container/commands/server/nodepinger.js:42:25)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4) {
code: 'InteractionAlreadyReplied'
}
@-Carlosπ
use
editReply()
instead of reply()
on the interactionfixed it
anothor problem with my other command embed
Error retrieving node information: TypeError: (intermediate value).setTitle(...).setColor(...).addField is not a function
at Object.execute (/home/container/commands/server/nodepinger.js:35:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4)
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const axios = require('axios');
module.exports = {
data: new SlashCommandBuilder()
.setName('node')
.setDescription('Retrieve information about a specific node.')
.addStringOption(option =>
option.setName('nodename')
.setDescription('Name of the node')
.setRequired(true)),
async execute(interaction) {
try {
if (interaction.deferred) return; // Check if already deferred
const nodeName = interaction.options.getString('nodename');
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer ptla_ZkiEC7bmMS5a6IvrfWwGI3Ue3EW1SFlxXigiJ2nrl4Y',
'Content-Type': 'application/json'
}
});
if (response.status === 200) {
const nodes = response.data.data;
const node = nodes.find(node => node.attributes.name.toLowerCase().startsWith(nodeName.toLowerCase()));
if (node) {
const embed = new EmbedBuilder()
.setTitle(
${node.attributes.name} Information
)
.setColor('#57F287')
.addField('Description', node.attributes.description || 'N/A')
.addField('Location ID', node.attributes.location_id)
.addField('FQDN', node.attributes.fqdn)
.addField('Scheme', node.attributes.scheme)
.addField('Memory', node.attributes.memory)
.addField('Disk', node.attributes.disk)
.addField('Maintenance Mode', node.attributes.maintenance_mode ? 'Enabled' : 'Disabled');
await interaction.reply({ embeds: [embed] });
} else {
await interaction.reply(Node with name "${nodeName}" not found.
);
}
} else {
await interaction.reply('Failed to retrieve node information.');
}
} catch (error) {
console.error('Error retrieving node information:', error);
await interaction.reply('Error retrieving node information.');
}
},
};it's
.addFields()
on v14ok
Error retrieving node information: CombinedPropertyError (2)
Received one or more errors
input[0]
| ValidationError > s.object(T)
| Expected the value to be an object, but received string instead
|
| Received:
| | 'Description'
input[1]
| ValidationError > s.object(T)
| Expected the value to be an object, but received string instead
|
| Received:
| | 'N/A'
at _ArrayValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:480:70)
at _ArrayValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:216:88)
at EmbedBuilder.addFields (/home/container/node_modules/@discordjs/builders/src/messages/embed/Embed.ts:116:29)
at Object.execute (/home/container/commands/server/nodepinger.js:35:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4
show your full code
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const axios = require('axios');
module.exports = {
data: new SlashCommandBuilder()
.setName('node')
.setDescription('Retrieve information about a specific node.')
.addStringOption(option =>
option.setName('nodename')
.setDescription('Name of the node')
.setRequired(true)),
async execute(interaction) {
try {
if (interaction.deferred) return; // Check if already deferred
const nodeName = interaction.options.getString('nodename');
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer no api key',
'Content-Type': 'application/json'
}
});
if (response.status === 200) {
const nodes = response.data.data;
const node = nodes.find(node => node.attributes.name.toLowerCase().startsWith(nodeName.toLowerCase()));
if (node) {
const embed = new EmbedBuilder()
.setTitle(
${node.attributes.name} Information
)
.setColor('#57F287')
.addFields('Description', node.attributes.description || 'N/A')
.addFields('Location ID', node.attributes.location_id)
.addFields('FQDN', node.attributes.fqdn)
.addFields('Scheme', node.attributes.scheme)
.addFields('Memory', node.attributes.memory)
.addFields('Disk', node.attributes.disk)
.addFields('Maintenance Mode', node.attributes.maintenance_mode ? 'Enabled' : 'Disabled');
await interaction.reply({ embeds: [embed] });
} else {
await interaction.reply(Node with name "${nodeName}" not found.
);
}
} else {
await interaction.reply('Failed to retrieve node information.');
}
} catch (error) {
console.error('Error retrieving node information:', error);
await interaction.reply('Error retrieving node information.');
}
},
};no..
so like this .addFields(
{ name: 'Field 1', value: 'Value 1' },
{ name: 'Field 2', value: 'Value 2' },
);
yeah
Error retrieving node information: CombinedPropertyError (3)
Received one or more errors
input[0]
| CombinedPropertyError (1)
| Received one or more errors
|
| input.value
| | ValidationError > s.string
| | Expected a string primitive
| |
| | Received:
| | | 1
input[3]
| CombinedPropertyError (1)
| Received one or more errors
|
| input.value
| | ValidationError > s.string
| | Expected a string primitive
| |
| | Received:
| | | 24576
input[4]
| CombinedPropertyError (1)
| Received one or more errors
|
| input.value
| | ValidationError > s.string
| | Expected a string primitive
| |
| | Received:
| | | 1024000
at _ArrayValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:480:70)
at _ArrayValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:216:88)
at EmbedBuilder.addFields (/home/container/node_modules/@discordjs/builders/src/messages/embed/Embed.ts:116:29)
at Object.execute (/home/container/commands/server/nodepinger.js:35:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/events/interactionCreate.js:16:4)
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const axios = require('axios');
module.exports = {
data: new SlashCommandBuilder()
.setName('node')
.setDescription('Retrieve information about a specific node.')
.addStringOption(option =>
option.setName('nodename')
.setDescription('Name of the node')
.setRequired(true)),
async execute(interaction) {
try {
if (interaction.deferred) return; // Check if already deferred
const nodeName = interaction.options.getString('nodename');
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer ',
'Content-Type': 'application/json'
}
});
if (response.status === 200) {
const nodes = response.data.data;
const node = nodes.find(node => node.attributes.name.toLowerCase().startsWith(nodeName.toLowerCase()));
if (node) {
const embed = new EmbedBuilder()
.setTitle(
await interaction.reply({ embeds: [embed] }); } else { await interaction.reply(
${node.attributes.name} Information
)
.setColor('#57F287')
.addFields(
{ name: 'Location ID', value: node.attributes.location_id },
{ name: 'FQDN', value: node.attributes.fqdn },
{ name: 'Scheme', value: node.attributes.scheme },
{ name: 'Memory', value: node.attributes.memory },
{ name: 'Disk', value: node.attributes.disk },
{ name: 'Maintenance Mode', value: node.attributes.maintenance_mode ? 'Enabled' : 'Disabled' }
);
await interaction.reply({ embeds: [embed] }); } else { await interaction.reply(
Node with name "${nodeName}" not found.
);
}
} else {
await interaction.reply('Failed to retrieve node information.');
}
} catch (error) {
console.error('Error retrieving node information:', error);
await interaction.reply('Error retrieving node information.');
}
},
};
@-Carlosπcan you atleast put your code on a code block
Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes
Inline Code:
`console.log('inline!');` becomes
console.log('inline!');
@-Carlosπ
embed fields values must be strings
ok
but how it node.thing.thing gonna change into a placeholder for the numner
by making them a string
ok
either use .toString() or put them inside a
${}
I would recommend using the second optiondo get rid of "" and replace with ${}
or "${string}"
you aren't using " on your fields
{ name: 'Location ID', value: "${node.attributes.location_id}" },
this
no, here's an example:
ok
.setTitle(
${node.attributes.name} Information
)
.setColor('#57F287')
.addFields(
{ name: 'Location ID', value: '${node.attributes.location_id}' },
{ name: 'FQDN', value: '${node.attributes.fqdn}' },
{ name: 'Scheme', value: '${node.attributes.scheme}' },
{ name: 'Memory', value: '${node.attributes.memory}' },
{ name: 'Disk', value: '${node.attributes.disk}' },
{ name: 'Maintenance Mode', value: '${node.attributes.maintenance_mode}' ? 'Enabled' : 'Disabled' }
);
`it's ` instead of '
ok
can help me add autocomple
node names
wdym
DE-1, "DE-2, "DE-3, GB-1 USA-1
for autocomple
i'm not really familiar with autocomplete, but you can check this out: https://discordjs.guide/slash-commands/autocomplete.html#autocomplete
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.