HAYYAMMM
Centipat
- Katılım
- 18 Ekim 2021
- Mesajlar
- 12
Daha fazla
- Cinsiyet
- Erkek
Herkese merhabalar, Dün akşam ChatGPT yardımıyla, Python kullanarak PyCharm üzerinden bir Discord Botu oluşturdum, kodu çalıştırdım bir hata almadım, botum şuan Discord üzerinde online gözüküyor ancak istediğim komuta bir türlü teki vermiyor, ilgili kodları aşağıya koyuyorum
Kodun yazılı hali:
Özetle botun amacını anlatayım: Bu site üzerindeki validatörlerin anlık bilgilerinin çıktısını versin istiyorum, örnek olarak bu linkteki gibi " Head: , Total Sampled Headers (DAS): Node Start Time: PayForBlob Count: Last PayForBlob: Last Sampled Time: Last Restart Time: Node Uptime: Uptime Score: gibi değerleri $node_id= ID formatında döndürmesini istiyorum. Ancak discord üzerinde belirtilen formatı yazınca hiçbir çıktı alamıyorum.
Discord Developer alanında da bütün intents'leri açtım bota bot ve administrator yetkisini verdim ancak nafile, yine olmuyor. Tek istediğim bu minvalde bir çıktı almak.
Technopat Developerlarına güveniyor, yardımlarınızı bekliyorum.
Kodun yazılı hali:
Kod:
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')
Özetle botun amacını anlatayım: Bu site üzerindeki validatörlerin anlık bilgilerinin çıktısını versin istiyorum, örnek olarak bu linkteki gibi " Head: , Total Sampled Headers (DAS): Node Start Time: PayForBlob Count: Last PayForBlob: Last Sampled Time: Last Restart Time: Node Uptime: Uptime Score: gibi değerleri $node_id= ID formatında döndürmesini istiyorum. Ancak discord üzerinde belirtilen formatı yazınca hiçbir çıktı alamıyorum.
Discord Developer alanında da bütün intents'leri açtım bota bot ve administrator yetkisini verdim ancak nafile, yine olmuyor. Tek istediğim bu minvalde bir çıktı almak.
Technopat Developerlarına güveniyor, yardımlarınızı bekliyorum.