π’»π“‡π‘’π’Άπ“€π“Ž
π’»π“‡π‘’π’Άπ“€π“Ž
DIAdiscord.js - Imagine an app
Created by π’»π“‡π‘’π’Άπ“€π“Ž on 4/21/2024 in #djs-questions
trying to load slash commands
deployCommandsF()
^

TypeError: deployCommandsF is not a function
at Object.<anonymous> (C:\Users\clou1\OneDrive\Desktop\atom bot\index.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:1378:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49

Node.js v21.6.2
PS C:\Users\clou1\OneDrive\Desktop\atom bot> node .
C:\Users\clou1\OneDrive\Desktop\atom bot\index.js:8
deployCommandsF()
^

TypeError: deployCommandsF is not a function
at Object.<anonymous> (C:\Users\clou1\OneDrive\Desktop\atom bot\index.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:1378:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49

Node.js v21.6.2
PS C:\Users\clou1\OneDrive\Desktop\atom bot>
deployCommandsF()
^

TypeError: deployCommandsF is not a function
at Object.<anonymous> (C:\Users\clou1\OneDrive\Desktop\atom bot\index.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:1378:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49

Node.js v21.6.2
PS C:\Users\clou1\OneDrive\Desktop\atom bot> node .
C:\Users\clou1\OneDrive\Desktop\atom bot\index.js:8
deployCommandsF()
^

TypeError: deployCommandsF is not a function
at Object.<anonymous> (C:\Users\clou1\OneDrive\Desktop\atom bot\index.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:1378:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49

Node.js v21.6.2
PS C:\Users\clou1\OneDrive\Desktop\atom bot>
64 replies
DIAdiscord.js - Imagine an app
Created by π’»π“‡π‘’π’Άπ“€π“Ž on 3/17/2024 in #djs-questions
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)
120 replies
DIAdiscord.js - Imagine an app
Created by π’»π“‡π‘’π’Άπ“€π“Ž on 3/16/2024 in #djs-questions
ReferenceError: client is not defined
const PTERO_URL = 'panel.';
const API_KEY = 'hheeh';
const NODES_ENDPOINT = `${PTERO_URL}/api/application/nodes`;
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });


client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
// Set up interval to ping nodes every 5 minutes
setInterval(pingNodes, 5 * 60 * 1000);
});

client.login('MTIxODM3NTk4OTE0MzQwNDYwNA.G21e3T.BXN5bmAXqXHIAg4-AKvAJp4UHVAxIyGKSbTu6g');

async function pingNodes() {
try {
const response = await axios.get(NODES_ENDPOINT, {
headers: {
'Authorization': `Bearer ${API_KEY}`
}
});
if (response.status === 200) {
const nodes = response.data.data;
const onlineNodes = nodes.filter(node => node.attributes.is_online);
updateEmbed(onlineNodes);
}
} catch (error) {
console.error('Error fetching nodes:', error.message);
}
}

function updateEmbed(onlineNodes) {
const embed = new Discord.MessageEmbed()
.setColor(onlineNodes.length > 0 ? 'GREEN' : 'RED')
.setTitle('Node Status')
.setDescription(onlineNodes.length > 0 ? 'All nodes are online' : 'No nodes are online')
.addField('Online Nodes:', onlineNodes.map(node => node.attributes.name).join('\n') || 'None');

const channel = client.channels.cache.get('1128825813991706655'); // Replace with your channel ID
if (channel) {
channel.send(embed)
.then(() => console.log('Node status updated'))
.catch(console.error);
} else {
console.error('Channel not found');
}
}
const PTERO_URL = 'panel.';
const API_KEY = 'hheeh';
const NODES_ENDPOINT = `${PTERO_URL}/api/application/nodes`;
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });


client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
// Set up interval to ping nodes every 5 minutes
setInterval(pingNodes, 5 * 60 * 1000);
});

client.login('MTIxODM3NTk4OTE0MzQwNDYwNA.G21e3T.BXN5bmAXqXHIAg4-AKvAJp4UHVAxIyGKSbTu6g');

async function pingNodes() {
try {
const response = await axios.get(NODES_ENDPOINT, {
headers: {
'Authorization': `Bearer ${API_KEY}`
}
});
if (response.status === 200) {
const nodes = response.data.data;
const onlineNodes = nodes.filter(node => node.attributes.is_online);
updateEmbed(onlineNodes);
}
} catch (error) {
console.error('Error fetching nodes:', error.message);
}
}

function updateEmbed(onlineNodes) {
const embed = new Discord.MessageEmbed()
.setColor(onlineNodes.length > 0 ? 'GREEN' : 'RED')
.setTitle('Node Status')
.setDescription(onlineNodes.length > 0 ? 'All nodes are online' : 'No nodes are online')
.addField('Online Nodes:', onlineNodes.map(node => node.attributes.name).join('\n') || 'None');

const channel = client.channels.cache.get('1128825813991706655'); // Replace with your channel ID
if (channel) {
channel.send(embed)
.then(() => console.log('Node status updated'))
.catch(console.error);
} else {
console.error('Channel not found');
}
}
Node.js v21.6.2 PS C:\Users\clou1\Downloads\archive-2024-03-16T014232Z> node . C:\Users\clou1\Downloads\archive-2024-03-16T014232Z\index.js:5 client.on('ready', () => { ^ ReferenceError: client is not defined at Object.<anonymous> (C:\Users\clou1\Downloads\archive-2024-03-16T014232Z\index.js:5:1) at Module._compile (node:internal/modules/cjs/loader:1378:14) at Module._extensions..js (node:internal/modules/cjs/loader:1437:10) at Module.load (node:internal/modules/cjs/loader:1212:32) at Module._load (node:internal/modules/cjs/loader:1028:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) at node:internal/main/run_main_module:28:49 Node.js v21.6.2 PS C:\Users\clou1\Downloads\archive-2024-03-16T014232Z> node . C:\Users\clou1\Downloads\archive-2024-03-16T014232Z\index.js:5 client.on('ready', () => { ^ ReferenceError: client is not defined at Object.<anonymous> (C:\Users\clou1\Downloads\archive-2024-03-16T014232Z\index.js:5:1) at Module._compile (node:internal/modules/cjs/loader:1378:14) at Module._extensions..js (node:internal/modules/cjs/loader:1437:10) at Module.load (node:internal/modules/cjs/loader:1212:32) at Module._load (node:internal/modules/cjs/loader:1028:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) at node:internal/main/run_main_module:28:49
13 replies