embed

const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js'); // Make sure this import is correct
const axios = require('axios');

module.exports = {
data: new SlashCommandBuilder()
.setName('nodeping')
.setDescription('Ping the nodes to check their status.'),

async execute(interaction) {
try {
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer no api key for y',
'Content-Type': 'application/json'
}
});

if (response.status === 200) {
const nodes = response.data.data;
const onlineNodes = nodes.filter(node => node.attributes.is_online);

const embed = new MessageEmbed()
.setTitle('Node Status')
.setDescription(onlineNodes.length > 0 ? 'Some nodes are online!' : 'No nodes are online!')
.setColor(onlineNodes.length > 0 ? 'GREEN' : 'RED');

onlineNodes.forEach(node => {
embed.addField('Online Node', node.attributes.name);
});

await interaction.reply({ embeds: [embed] });
} else {
await interaction.reply('Failed to ping the nodes.');
}
} catch (error) {
console.error('Error pinging the nodes:', error);
await interaction.reply('Error pinging the nodes.');
}
},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js'); // Make sure this import is correct
const axios = require('axios');

module.exports = {
data: new SlashCommandBuilder()
.setName('nodeping')
.setDescription('Ping the nodes to check their status.'),

async execute(interaction) {
try {
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer no api key for y',
'Content-Type': 'application/json'
}
});

if (response.status === 200) {
const nodes = response.data.data;
const onlineNodes = nodes.filter(node => node.attributes.is_online);

const embed = new MessageEmbed()
.setTitle('Node Status')
.setDescription(onlineNodes.length > 0 ? 'Some nodes are online!' : 'No nodes are online!')
.setColor(onlineNodes.length > 0 ? 'GREEN' : 'RED');

onlineNodes.forEach(node => {
embed.addField('Online Node', node.attributes.name);
});

await interaction.reply({ embeds: [embed] });
} else {
await interaction.reply('Failed to ping the nodes.');
}
} catch (error) {
console.error('Error pinging the nodes:', error);
await interaction.reply('Error pinging the nodes.');
}
},
};
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
d.js toolkit
d.js toolkit•3mo 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!
ssspussywolf
ssspussywolf•3mo ago
bump s
-Carlosđź‘‘
-Carlos👑•3mo ago
it's EmbedBuilder for v14
ssspussywolf
ssspussywolf•3mo ago
ty 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
-Carlosđź‘‘
-Carlos👑•3mo ago
you didn't change it you forgot to change it on your interactionCreate event
ssspussywolf
ssspussywolf•3mo ago
where
-Carlosđź‘‘
-Carlos👑•3mo ago
^
ssspussywolf
ssspussywolf•3mo ago
:i dont understand wher e
-Carlosđź‘‘
-Carlos👑•3mo ago
go to your interactionCreate.js file and change MessageEmbed to EmbedBuilder
ssspussywolf
ssspussywolf•3mo ago
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đź‘‘
-Carlosđź‘‘
-Carlos👑•3mo ago
is that your full code
ssspussywolf
ssspussywolf•3mo ago
yes
-Carlosđź‘‘
-Carlos👑•3mo ago
can you run npm list discord.js on your console wait, did you save the file
ssspussywolf
ssspussywolf•3mo ago
yes
-Carlosđź‘‘
-Carlos👑•3mo ago
are you sure
ssspussywolf
ssspussywolf•3mo ago
yes @-Carlosđź‘‘
-Carlosđź‘‘
-Carlos👑•3mo ago
did you also change it on the const embed = new MessageEmbed() part? also can you stop pinging me
ssspussywolf
ssspussywolf•3mo ago
what am i gonna change it to const embed = new MessageEmbed()
-Carlosđź‘‘
-Carlos👑•3mo ago
^
ssspussywolf
ssspussywolf•3mo ago
ok const embed = new EmbedBuilder () to that
-Carlosđź‘‘
-Carlos👑•3mo ago
yeah remove that extra space
ssspussywolf
ssspussywolf•3mo ago
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' }
-Carlosđź‘‘
-Carlos👑•3mo ago
embed colors are PascalCase
ssspussywolf
ssspussywolf•3mo ago
do this #57F287
-Carlosđź‘‘
-Carlos👑•3mo ago
yeah if you want to use a hex color instead that should work
ssspussywolf
ssspussywolf•3mo ago
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' }
d.js docs
d.js docs•3mo ago
To share long code snippets, use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks or files.
-Carlosđź‘‘
-Carlos👑•3mo ago
show your full code
-Carlosđź‘‘
-Carlos👑•3mo ago
full code, not full error
ssspussywolf
ssspussywolf•3mo ago
ok
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js'); // Make sure this import is correct
const axios = require('axios');

module.exports = {
data: new SlashCommandBuilder()
.setName('nodeping')
.setDescription('Ping the nodes to check their status.'),

async execute(interaction) {
try {
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer no api key for u :0',
'Content-Type': 'application/json'
}
});

if (response.status === 200) {
const nodes = response.data.data;
const onlineNodes = nodes.filter(node => node.attributes.is_online);

const embed = new EmbedBuilder()
.setTitle('Node Status')
.setDescription(onlineNodes.length > 0 ? 'Some nodes are online!' : 'No nodes are online!')
.setColor(onlineNodes.length > 0 ? '#57F287' : '#ED4245');

onlineNodes.forEach(node => {
embed.addField('Online Node', node.attributes.name);
});

await interaction.reply({ embeds: [embed] });
} else {
await interaction.reply('Failed to ping the nodes.');
}
} catch (error) {
console.error('Error pinging the nodes:', error);
await interaction.reply('Error pinging the nodes.');
}
},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js'); // Make sure this import is correct
const axios = require('axios');

module.exports = {
data: new SlashCommandBuilder()
.setName('nodeping')
.setDescription('Ping the nodes to check their status.'),

async execute(interaction) {
try {
const response = await axios.get('https://panel.nauticalmc.net/api/application/nodes', {
headers: {
Authorization: 'Bearer no api key for u :0',
'Content-Type': 'application/json'
}
});

if (response.status === 200) {
const nodes = response.data.data;
const onlineNodes = nodes.filter(node => node.attributes.is_online);

const embed = new EmbedBuilder()
.setTitle('Node Status')
.setDescription(onlineNodes.length > 0 ? 'Some nodes are online!' : 'No nodes are online!')
.setColor(onlineNodes.length > 0 ? '#57F287' : '#ED4245');

onlineNodes.forEach(node => {
embed.addField('Online Node', node.attributes.name);
});

await interaction.reply({ embeds: [embed] });
} else {
await interaction.reply('Failed to ping the nodes.');
}
} catch (error) {
console.error('Error pinging the nodes:', error);
await interaction.reply('Error pinging the nodes.');
}
},
};
umm u there
-Carlosđź‘‘
-Carlos👑•3mo ago
yeah
d.js docs
d.js docs•3mo ago
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 responses
-Carlosđź‘‘
-Carlos👑•3mo ago
most likely that axios call took more than 3 seconds
ssspussywolf
ssspussywolf•3mo ago
how to fix
-Carlosđź‘‘
-Carlos👑•3mo ago
it says it here
ssspussywolf
ssspussywolf•3mo ago
dont understand
-Carlosđź‘‘
-Carlos👑•3mo ago
- Initial response took more than 3 seconds âžž defer the response *.
ssspussywolf
ssspussywolf•3mo ago
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đź‘‘
-Carlosđź‘‘
-Carlos👑•3mo ago
you literally just need to defer the reply
ssspussywolf
ssspussywolf•3mo ago
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
-Carlosđź‘‘
-Carlos👑•3mo ago
yeah, but don't use ChatGPT
ssspussywolf
ssspussywolf•3mo ago
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đź‘‘
-Carlosđź‘‘
-Carlos👑•3mo ago
use editReply() instead of reply() on the interaction
ssspussywolf
ssspussywolf•3mo ago
fixed 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.'); } }, };
-Carlosđź‘‘
-Carlos👑•3mo ago
it's .addFields() on v14
ssspussywolf
ssspussywolf•3mo ago
ok 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
-Carlosđź‘‘
-Carlos👑•3mo ago
show your full code
ssspussywolf
ssspussywolf•3mo ago
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.'); } }, };
-Carlosđź‘‘
-Carlos👑•3mo ago
no..
d.js docs
d.js docs•3mo ago
:method: EmbedBuilder#addFields() Appends fields to the embed
ssspussywolf
ssspussywolf•3mo ago
so like this .addFields( { name: 'Field 1', value: 'Value 1' }, { name: 'Field 2', value: 'Value 2' }, );
-Carlosđź‘‘
-Carlos👑•3mo ago
yeah
ssspussywolf
ssspussywolf•3mo ago
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(${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đź‘‘
-Carlosđź‘‘
-Carlos👑•3mo ago
can you atleast put your code on a code block
d.js docs
d.js docs•3mo ago
Codeblocks: ```js const Discord = require("discord.js"); // further code ``` becomes
const Discord = require("discord.js");
// further code
const Discord = require("discord.js");
// further code
Inline Code: `console.log('inline!');` becomes console.log('inline!');
ssspussywolf
ssspussywolf•3mo ago
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(${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.');
}
},
};
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(${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đź‘‘
-Carlosđź‘‘
-Carlos👑•3mo ago
embed fields values must be strings
ssspussywolf
ssspussywolf•3mo ago
ok but how it node.thing.thing gonna change into a placeholder for the numner
-Carlosđź‘‘
-Carlos👑•3mo ago
by making them a string
ssspussywolf
ssspussywolf•3mo ago
ok
-Carlosđź‘‘
-Carlos👑•3mo ago
either use .toString() or put them inside a ${} I would recommend using the second option
ssspussywolf
ssspussywolf•3mo ago
do get rid of "" and replace with ${} or "${string}"
-Carlosđź‘‘
-Carlos👑•3mo ago
you aren't using " on your fields
ssspussywolf
ssspussywolf•3mo ago
{ name: 'Location ID', value: "${node.attributes.location_id}" }, this
-Carlosđź‘‘
-Carlos👑•3mo ago
no, here's an example:
.addFields({ name: 'Location ID', value: `${node.attributes.location_id}` });
.addFields({ name: 'Location ID', value: `${node.attributes.location_id}` });
ssspussywolf
ssspussywolf•3mo ago
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' } ); `
-Carlosđź‘‘
-Carlos👑•3mo ago
it's ` instead of '
ssspussywolf
ssspussywolf•3mo ago
ok can help me add autocomple
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(`${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}`}
);

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.');
}
},
};
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(`${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}`}
);

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.');
}
},
};
node names
-Carlosđź‘‘
-Carlos👑•3mo ago
wdym
ssspussywolf
ssspussywolf•3mo ago
DE-1, "DE-2, "DE-3, GB-1 USA-1 for autocomple
-Carlosđź‘‘
-Carlos👑•3mo ago
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.