import discord
import requests
from discord.ext import commands
# Create a new Intents object
intents = discord.Intents.default()
# Enable the necessary privileged intents
intents.guilds = True
intents.members = True
intents.messages = True
# Instantiate the bot object with the intents parameter
bot = commands.Bot(command_prefix='$', intents=intents)
@bot.command()
async def node(ctx, *, node_id):
# Extract node ID from user input
node_id = node_id.split('=')[1]
# Send a request to Celestia API to get node information
url = f'https://api.celestia.org/node/{node_id}/status'
response = requests.get(url)
# Check if node information is retrieved successfully
if response.status_code != 200:
await ctx.send('Node information could not be retrieved.')
return
# Parse node information from response
node_info = response.json()
node_status = node_info['status']
# Format and send node information as a message to Discord channel
message = (f'Head: {node_status["head"]}\n'
f'Total Sampled Headers (DAS): {node_status["das_count"]}\n'
f'Node Start Time: {node_status["node_start_time"]}\n'
f'PayForBlob Count: {node_status["pfob_count"]}\n'
f'Last PayForBlob: {node_status["last_pfob"]}\n'
f'Last Sampled Time: {node_status["last_sampled_time"]}\n'
f'Last Restart Time: {node_status["last_restart_time"]}\n'
f'Node Uptime: {node_status["node_uptime"]}\n'
f'Uptime Score: {node_status["uptime_score"]}')
await ctx.send(message)
bot.run('MTA5NTQzOTYzMTYyMjg3NzIzNg.G69i8O.Dba18_gaONI8fU9AHT64uRNey_W0ph1bzJfK8U')