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');
}
}