add kp index command

This commit is contained in:
Xaloc 2023-03-20 20:43:40 +01:00
parent 0ea6e64b44
commit a1b6e94e20

View File

@ -5,6 +5,7 @@ import discord
from discord.ext import commands
import config
import random
import requests
TOKEN = config.token
ID = config.channel_id
@ -24,4 +25,18 @@ async def ASC(ctx):
await ctx.send(message)
return
@bot.command(name='kp', help='Shows the current Kp index')
async def kp(ctx):
response = requests.get('https://services.swpc.noaa.gov/products/noaa-planetary-k-index.json')
data = response.json()
kp = data[-1][1]
message = f'The current Kp index is {kp}'
if ctx.channel.id != ID:
await ctx.send(f"Please keep this stuff in <#{ID}>")
return
else:
await ctx.send(message)
return
bot.run(TOKEN)