From a1b6e94e20deea58fee095ded4b97a0ff36418ee Mon Sep 17 00:00:00 2001 From: Xaloc Date: Mon, 20 Mar 2023 20:43:40 +0100 Subject: [PATCH] add kp index command --- auroraBot.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/auroraBot.py b/auroraBot.py index 81091c4..57b1ff3 100644 --- a/auroraBot.py +++ b/auroraBot.py @@ -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) \ No newline at end of file