From 227534caaa282e18f4170b7e94efdad78a346aba Mon Sep 17 00:00:00 2001 From: jmueller Date: Mon, 11 Dec 2023 18:31:44 +0100 Subject: [PATCH] Supported 0 votes --- main.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 43e93a6..4d1a9bc 100644 --- a/main.py +++ b/main.py @@ -450,14 +450,28 @@ class delete_and_view_votes_message(discord.ui.View): @discord.ui.button(label="Stimme auswählen und löschen", custom_id="delete-votes", style=discord.ButtonStyle.secondary) async def delete_votes(self, button, interaction): - embed = discord.Embed( - title="Stimme löschen", - description="Wähle einen Rekruten aus, um deine Stimme für ihn zu löschen", - color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from - ) - delete_recruit_vote_inst = delete_recruit_vote() - delete_recruit_vote_inst.children[0].options = getvotes(interaction.user.id) - await interaction.response.send_message(embed=embed, view=delete_recruit_vote_inst, ephemeral=True) + cur.execute("SELECT count(yes_votes.id) FROM recruits, yes_votes WHERE recruits.discord_id = yes_votes.discord_id_recruit AND recruits.recruit = 1 AND yes_votes.discord_id_voter = ?", (interaction.user.id,)) + yes_votes = cur.fetchone()[0] + cur.execute("SELECT count(no_votes.id) FROM recruits, no_votes WHERE recruits.discord_id = no_votes.discord_id_recruit AND recruits.recruit = 1 AND no_votes.discord_id_voter = ?", (interaction.user.id,)) + no_votes = cur.fetchone()[0] + count = yes_votes + no_votes + if count == 0: + embed = discord.Embed( + title="Keine Stimmen gefunden.", + description="Du hast keine Stimmen abgeben! Zock mit den Rekruten und fang an!", + color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from + ) + embed.set_footer(text="Wenn du denkst, dass dies nicht korrekt ist, wende dich bitte an LordofAgents.") + await interaction.response.send_message(embed=embed, ephemeral=True) + else: + embed = discord.Embed( + title="Stimme löschen", + description="Wähle einen Rekruten aus, um deine Stimme für ihn zu löschen", + color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from + ) + delete_recruit_vote_inst = delete_recruit_vote() + delete_recruit_vote_inst.children[0].options = getvotes(interaction.user.id) + await interaction.response.send_message(embed=embed, view=delete_recruit_vote_inst, ephemeral=True) def getvotes(voterid, part = 1): @@ -580,6 +594,9 @@ async def message_voting(ctx): conn.commit() await ctx.respond(f"Done.", ephemeral=True) +# HIER + + @settings.command(description="Sendet den Report in den aktuellen Kanal.") @default_permissions(manage_roles=True) async def message_report(ctx):