From 61d74583b5b008a14e20c71488720a8c69ff3c7b Mon Sep 17 00:00:00 2001 From: jmueller Date: Mon, 11 Dec 2023 19:17:37 +0100 Subject: [PATCH] Created Report Embed --- main.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 4d1a9bc..217bcee 100644 --- a/main.py +++ b/main.py @@ -594,8 +594,27 @@ async def message_voting(ctx): conn.commit() await ctx.respond(f"Done.", ephemeral=True) -# HIER - +async def create_report_embed(): + embed = discord.Embed( + title="Aktuelle Stimmen", + color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from + ) + cur.execute("SELECT recruits.nickname, count(yes_votes.id), count(no_votes.id), recruits.discord_id FROM recruits LEFT JOIN no_votes ON recruits.discord_id = no_votes.discord_id_recruit LEFT JOIN yes_votes ON recruits.discord_id = yes_votes.discord_id_recruit WHERE recruits.recruit = 1 GROUP BY recruits.nickname") + recruits = cur.fetchall() + description = "" + cur.execute("SELECT value FROM settings WHERE name = ?", ("guild", )) + guild_id = cur.fetchone() + guild = bot.get_guild(guild_id) + for recruit in recruits: + if recruit[2] != 0: + cur.execute("SELECT reason, discord_id_voter FROM no_votes WHERE discord_id_recruit = ?", (recruits[3])) + no_votes = cur.fetchone() + description = description + "**" + recruit[0] + ":**" + recruit[1] + "Ja, " + recruit[2] + "Nein.\n" + for no_vote in no_votes: + description = description + "Begründung von " + guild.get_member(no_vote[1]).display_name + ": " + no_vote[0] + "\n\n" + else: + description = description + "**" + recruit[0] + ":**" + recruit[1] + "Ja, " + recruit[2] + "Nein.\n" + return embed @settings.command(description="Sendet den Report in den aktuellen Kanal.") @default_permissions(manage_roles=True)