Skip to content

Commit

Permalink
FINALLY CAN PASS PERSON BETWEEN MODALS
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 4, 2023
1 parent 3c273e8 commit 322d90d
Showing 1 changed file with 56 additions and 8 deletions.
64 changes: 56 additions & 8 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 322d90d

Please sign in to comment.