Implemented Generation of Report

This commit is contained in:
jmueller
2023-12-14 21:38:01 +01:00
parent 5969b52c54
commit cf60ad7381

41
main.py
View File

@@ -723,6 +723,36 @@ class report_select_menu50(discord.ui.View):
async def on_timeout(self):
self.clear_items()
class generate_report25(discord.ui.View):
@discord.ui.select( # the decorator that lets you specify the properties of the select menu
placeholder="Rekruten wählen...", # the placeholder text that will be displayed if nothing is selected
min_values=1, # the minimum number of values that must be selected by the users
max_values=get_count_recruits(), # the maximum number of values that can be selected by the users
options=[]
)
async def select_callback(self, select, interaction):
await interaction.response.defer(ephemeral=True)
embed = discord.Embed(
title="Rekrutenbesichtigung: Erstellter Report",
color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from
)
description = "```\n"
guild = interaction.guild
for recruit in select.values:
cur.execute("SELECT recruits.nickname, count(yes_votes.id), count(no_votes.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.discord_id = ?", (recruit, ))
data = cur.fetchall()
description = description + "**" + data[0] + ":** " + data[1] + " Ja | " + data[2] + "Nein -> \n"
if data[1] != 0:
cur.execute("SELECT discord_id_voter, reason FROM no_votes WHERE discord_id_recruit = ?", (recruit, ))
no_votes = cur.fetchall()
for vote in no_votes:
nick = guild.get_member(vote[0]).display_name
description = description + "Begründung von " + nick + ": " + vote[1] + "\n"
description = description + "\n\n"
embed.description = description
await interaction.followup.send(embed=embed)
class report_buttons(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@@ -742,9 +772,16 @@ class report_buttons(discord.ui.View):
report_select_menu50_inst.children[1].options = build_option_list(2)[0]
await interaction.response.send_message(embed=embed, view=report_select_menu50_inst, ephemeral=True)
@discord.ui.button(label="Rekruten auschecken", style=discord.ButtonStyle.primary, row=1, custom_id="report_buttons_checkout")
@discord.ui.button(label="Rekrutenbesichtigung generieren", style=discord.ButtonStyle.primary, row=1, custom_id="report_buttons_checkout")
async def checkout_recruits(self, button, interaction):
await interaction.response.send_message("Äääh ich funktioniere noch nicht. Sorrryyyyyy :D", ephemeral=True)
generate_report25_inst = generate_report25()
generate_report25_inst.children[0].options = build_option_list()
embed = discord.Embed(
title="Rekrut wählen",
description="Bitte wähle einen oder mehrere Rekruten aus",
color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from
)
interaction.response.send_message(embed=embed, view=generate_report25_inst)
@discord.ui.button(label="Daten aktualisieren", style=discord.ButtonStyle.secondary, row=2, custom_id="report_buttons_refresh")
async def refresh_button(self, button, interaction):