From c77c91dbe173dd4cf18ffd8ea230113416f3fb77 Mon Sep 17 00:00:00 2001 From: deflax Date: Tue, 16 Jan 2024 19:11:09 +0200 Subject: [PATCH] iterate values of the dict items --- src/discordbot/discordbot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/discordbot/discordbot.py b/src/discordbot/discordbot.py index 7615495..9e4f813 100644 --- a/src/discordbot/discordbot.py +++ b/src/discordbot/discordbot.py @@ -45,17 +45,15 @@ async def epg(ctx): response.raise_for_status() content = response.json() await ctx.channel.send('epg:') - await ctx.channel.send(type(content)) - await ctx.channel.send(f'`{content}`') - + if content != {}: - for item in content: - if item['start_at'] == 'now' or item['start_at'] == 'never': + for key, value in content.items(): + if value['start_at'] == 'now' or value['start_at'] == 'never': await ctx.channel.send('x') continue else: await ctx.channel.send('x') - await ctx.channel.send(item['start_at']) + await ctx.channel.send(value['start_at']) else: await ctx.channel.send('Empty database!') except Exception as e: @@ -70,6 +68,10 @@ async def start_task(ctx): # Schedule a task to run every 5 seconds scheduler.add_job(func=my_task, id='my_task_id') #scheduler.add_job(func=tick, id='tick_id', args=(ctx)) + #channel = bot.get_channel(channel_id) + #if channel: + # # Send the message to the specified channel + # await channel.send(message) @bot.command(name='show') async def show_task(ctx):