From deea320d98a510dbd4295d815565d06e1e642766 Mon Sep 17 00:00:00 2001 From: deflax Date: Tue, 16 Jan 2024 18:42:23 +0200 Subject: [PATCH] return json from the db request --- src/discordbot/discordbot.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/discordbot/discordbot.py b/src/discordbot/discordbot.py index b626b47..86955b1 100644 --- a/src/discordbot/discordbot.py +++ b/src/discordbot/discordbot.py @@ -41,16 +41,19 @@ async def epg(ctx): if requests.get(db_url).status_code == 200: response = requests.get(db_url) response.raise_for_status() - content = response.text - await ctx.channel.send(type(content)) - - for item in content: - if item['start_at'] == 'now' or item['start_at'] == 'never': - await ctx.channel.send('x') - continue - else: - await ctx.channel.send('y') - await ctx.channel.send(item['start_at']) + content = response.json + await ctx.channel.send('epg:') + + if content != {}: + for item in content: + if item['start_at'] == 'now' or item['start_at'] == 'never': + await ctx.channel.send('x') + continue + else: + await ctx.channel.send('x') + await ctx.channel.send(item['start_at']) + else: + await ctx.channel.send('Empty database!') except Exception as e: print(e)