From 322d90ddc9182a4595bfc0122bd20a148c804339 Mon Sep 17 00:00:00 2001 From: Selyss <99344963+Selyss@users.noreply.github.com> Date: Sun, 3 Dec 2023 21:49:39 -0500 Subject: [PATCH] FINALLY CAN PASS PERSON BETWEEN MODALS --- cogs/inquiry.py | 64 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/cogs/inquiry.py b/cogs/inquiry.py index 6d35e16..db2ebbf 100644 --- a/cogs/inquiry.py +++ b/cogs/inquiry.py @@ -47,10 +47,53 @@ async def advertisement(self, btn: nextcord.ui.Button, inter: nextcord.Interacti await inter.response.send_modal(AdForm()) -# TODO: not implemented +class QuickResponse(nextcord.ui.Modal): + def __init__(self, person) -> None: + super().__init__( + title="Quick Response", + custom_id="persistant_modal:quickresponse", + timeout=None, + ) + self.person = person + + self.details = nextcord.ui.TextInput( + label="Response", + style=nextcord.TextInputStyle.paragraph, + placeholder="Response here...", + required=True, + max_length=1800, + custom_id="persistant_modal:quickresponse_response", + ) + self.add_item(self.details) + + async def callback(self, inter: nextcord.Interaction) -> None: + if isinstance(inter.channel, nextcord.TextChannel): + category = nextcord.utils.get(inter.guild.categories, id=TICKET_CATEGORY) + new_channel = await category.create_text_channel( + name=f"ticket-{inter.user.name}", + reason=f"Created ticket for {inter.user.id} - {inter.user.name}", + topic=self.person.user.id, + ) + await inter.response.send_message( + f"Ticket created: <#{new_channel.id}>", ephemeral=True + ) + em = nextcord.Embed() + em.color = AD_EMBED_COLOR + em.add_field(name="**CONTACT REQUEST ACCEPTED**", value="", inline=False) + em.add_field(name="**message**", value=self.details.value, inline=False) + em.set_footer(text=f"{inter.user.id} ā€¢ {get_date()} ā€¢ {get_time()}") + + await new_channel.send( + content=f"<@{inter.user.id}>", + embed=em, + view=AdView(), + ) + + class RequestView(nextcord.ui.View): - def __init__(self) -> None: + def __init__(self, person) -> None: super().__init__(timeout=None) + self.person = person @nextcord.ui.button( label="Accept", style=nextcord.ButtonStyle.green, custom_id="ticket:accept" @@ -59,13 +102,14 @@ async def accept(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): pass @nextcord.ui.button( - label="Reject", style=nextcord.ButtonStyle.red, custom_id="ticket:reject" + label="Quick Response", + style=nextcord.ButtonStyle.red, + custom_id="ticket:reject", ) - async def reject(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): - pass + async def quickresponse(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): + await inter.response.send_modal(QuickResponse(self.person)) -# TODO: not implemented class AdView(nextcord.ui.View): def __init__(self) -> None: super().__init__(timeout=None) @@ -101,6 +145,7 @@ async def callback(self, inter: nextcord.Interaction) -> None: new_channel = await category.create_text_channel( name=f"ticket-{inter.user.name}", reason=f"Created ticket for {inter.user.id} - {inter.user.name}", + topic=inter.user.id, ) await inter.response.send_message( f"Ticket created: <#{new_channel.id}>", ephemeral=True @@ -117,6 +162,9 @@ async def callback(self, inter: nextcord.Interaction) -> None: embed=em, view=AdView(), ) + await new_channel.send( + content="""--------------------------------------------\n__**ADVERTISEMENT SERVICES**__\n\nšŸ”” $40 = Ping @ everyone with ad message/links\n\nšŸŽ $45 = Hosted Nitro Giveaway Ad with @ everyone ping (Nitro must be supplied by the customer)\n\n*These prices apply to the Vanilla PvP Community/Tier List*\n--------------------------------------------""" + ) class QuestionForm(nextcord.ui.Modal): @@ -145,7 +193,7 @@ async def callback(self, inter: nextcord.Interaction) -> None: em.add_field(name="**reason**", value=self.details.value) em.set_footer(text=f"{inter.user.id} ā€¢ {get_date()} ā€¢ {get_time()}") - await target_channel.send(embed=em, view=RequestView()) + await target_channel.send(embed=em, view=RequestView(person=inter)) class Inquiry(Cog): @@ -156,7 +204,7 @@ def __init__(self, bot: Bot) -> None: @Cog.listener() async def on_ready(self) -> None: if not self.persistent_modal_added: - self.bot.add_view(RequestView()) + self.bot.add_view(RequestView(None)) self.bot.add_view(TicketView()) self.bot.add_view(AdView()) self.persistent_modal_added = True