From 2c276421c021d66d31acb0339e986358ab42de87 Mon Sep 17 00:00:00 2001 From: Selyss <99344963+Selyss@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:13:08 -0500 Subject: [PATCH] bunimokpl[;]' --- cogs/inquiry.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cogs/inquiry.py b/cogs/inquiry.py index 49cde71..f143d3c 100644 --- a/cogs/inquiry.py +++ b/cogs/inquiry.py @@ -164,11 +164,28 @@ async def callback(self, inter: nextcord.Interaction) -> None: ) +def create_button(button_id): + @nextcord.ui.button( + label="Quick Response", + style=nextcord.ButtonStyle.blurple, + custom_id=f"ticket:{button_id}", + ) + async def quickresponse(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): + p = str(btn.custom_id).split(":") + await inter.response.send_modal(QuickResponse(person=p[1])) + + return quickresponse + + class RequestView(nextcord.ui.View): - def __init__(self, person=None, message=None) -> None: + def __init__(self, person: int, message) -> None: super().__init__(timeout=None) - self.person = person self.message = message + try: + on_button_click = create_button(person) + self.add_item(on_button_click) + except TypeError: + pass @nextcord.ui.button( label="Accept", style=nextcord.ButtonStyle.green, custom_id="requestview:accept" @@ -198,15 +215,6 @@ async def accept(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): view=CloseView(), ) - @nextcord.ui.button( - label="Quick Response", - style=nextcord.ButtonStyle.blurple, - custom_id="ticket:ID", ### SUB ID?? - ) - async def quickresponse(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): - p = str(btn.custom_id).split(":") - await inter.response.send_modal(QuickResponse(person=p[1])) - class AdView(nextcord.ui.View): def __init__(self) -> None: @@ -345,7 +353,7 @@ async def on_ready(self) -> None: self.persistent_modals_added = True if not self.persistent_views_added: - self.bot.add_view(RequestView()) + # self.bot.add_view(RequestView(None, None)) self.bot.add_view(TicketView()) self.bot.add_view(AdView()) self.bot.add_view(CloseView())