Implemented detailed report
This commit is contained in:
76
main.py
76
main.py
@@ -565,6 +565,7 @@ class confirm_deletion_of_vote(discord.ui.View): # Create a class called MyView
|
||||
color=discord.Colour.green(),
|
||||
)
|
||||
await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||
await edit_report_message()
|
||||
await self.message.delete()
|
||||
|
||||
@discord.ui.button(label="Abbrechen", style=discord.ButtonStyle.secondary)
|
||||
@@ -587,6 +588,33 @@ async def send_delete_message(channel):
|
||||
message = await channel.send(embed=embed, view=delete_and_view_votes_message())
|
||||
cur.execute("UPDATE settings SET VALUE = ? WHERE name = 'message_delete_vote'", (message.id, ))
|
||||
|
||||
async def process_detailed_report(select, interaction):
|
||||
cur.execute("SELECT nickname FROM recruits WHERE discord_id = ?", (select.values[0],))
|
||||
nick = cur.fetchone()[0]
|
||||
embed = discord.Embed(
|
||||
title="Abstimmungen für " + nick,
|
||||
color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from
|
||||
)
|
||||
cur.execute("SELECT discord_id_voter FROM yes_votes WHERE discord_id_recruit = ?", (select.values[0],))
|
||||
yes_votes = cur.fetchall()
|
||||
yes_vote = ""
|
||||
cur.execute("SELECT value FROM settings WHERE name = ?", ("guild",))
|
||||
guild_id = cur.fetchone()[0]
|
||||
guild = bot.get_guild(guild_id)
|
||||
for vote in yes_votes:
|
||||
yes_vote = yes_vote + guild.get_member(vote[0]).display_name + "\n"
|
||||
cur.execute("SELECT count(*) FROM yes_votes WHERE discord_id_recruit = ?", (select.values[0],))
|
||||
count_yes_votes = cur.fetchone()[0]
|
||||
embed.add_field(name="Ja-Stimmen (" + str(count_yes_votes) + "):", value=yes_vote)
|
||||
cur.execute("SELECT discord_id_voter, reason FROM no_votes WHERE discord_id_recruit = ?", (select.values[0],))
|
||||
no_votes = cur.fetchall()
|
||||
no_vote_text = ""
|
||||
for vote in no_votes:
|
||||
no_vote_text = no_vote_text + "**" + guild.get_member(vote[0]).display_name + "**: " + vote[1] + "\n"
|
||||
cur.execute("SELECT count(*) FROM no_votes WHERE discord_id_recruit = ?", (select.values[0],))
|
||||
count_no_votes = cur.fetchone()[0]
|
||||
embed.add_field(name="Nein-Stimmen (" + str(count_no_votes) + "):", value=no_vote_text)
|
||||
await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||
|
||||
@settings.command(description="Sendet die Nachricht zum Abstimmen in den aktuellen Channel.")
|
||||
@default_permissions(manage_roles=True)
|
||||
@@ -598,12 +626,58 @@ async def message_voting(ctx):
|
||||
conn.commit()
|
||||
await ctx.respond(f"Done.", ephemeral=True)
|
||||
|
||||
class report_select_menu25(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 = 1, # the maximum number of values that can be selected by the users
|
||||
options = build_option_list()[0]
|
||||
)
|
||||
async def select_callback(self, select, interaction):
|
||||
await self.message.delete()
|
||||
await process_detailed_report(select, interaction)
|
||||
|
||||
class report_select_menu50(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 = 1, # the maximum number of values that can be selected by the users
|
||||
options = build_option_list()[0],
|
||||
row=1
|
||||
)
|
||||
async def select1(self, select, interaction):
|
||||
await self.message.delete()
|
||||
await process_detailed_report(select, interaction)
|
||||
|
||||
@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 = 1, # the maximum number of values that can be selected by the users
|
||||
options = build_option_list()[1],
|
||||
row=2
|
||||
)
|
||||
async def select2(self, select, interaction):
|
||||
await self.message.delete()
|
||||
await process_detailed_report(select, interaction)
|
||||
|
||||
class report_buttons(discord.ui.View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
@discord.ui.button(label="Auswertung pro Rekrut", style=discord.ButtonStyle.primary, row=1, custom_id="report_buttons_pro_person")
|
||||
async def report_per_recruit(self, button, interaction):
|
||||
await interaction.response.send_message("You clicked the button!")
|
||||
embed = discord.Embed(
|
||||
title="Bitte wähle einen Rekruten aus",
|
||||
color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from
|
||||
)
|
||||
if get_count_recruits(1) <= 25:
|
||||
report_select_menu25_inst = report_select_menu25()
|
||||
report_select_menu25_inst.options = build_option_list(1)
|
||||
await interaction.response.send_message(embed=embed, view=report_select_menu25_inst, ephemeral=True)
|
||||
else:
|
||||
report_select_menu50_inst = report_select_menu50()
|
||||
report_select_menu50_inst.options[0] = build_option_list(1)
|
||||
report_select_menu50_inst.options[1] = build_option_list(2)
|
||||
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")
|
||||
async def checkout_recruits(self, button, interaction):
|
||||
|
||||
Reference in New Issue
Block a user