From 897e7162823ef745e6376df633b452c874911801 Mon Sep 17 00:00:00 2001 From: Selyss <99344963+Selyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:19:48 -0500 Subject: [PATCH] move CloseView to views --- cogs/inquiry.py | 20 ++------------------ views/close.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 views/close.py diff --git a/cogs/inquiry.py b/cogs/inquiry.py index da87835..ba8c1c3 100644 --- a/cogs/inquiry.py +++ b/cogs/inquiry.py @@ -7,6 +7,7 @@ from .utils.colors import EMBED_COLOR, SUCCESS, INQUIRY, REPLY, AD_EM_COLOR from .utils.formatting import format_footer from views.ad import AdView +from views.close import CloseView load_dotenv() @@ -58,23 +59,6 @@ async def advertisement(self, btn: nextcord.ui.Button, inter: nextcord.Interacti await inter.response.send_modal(AdForm()) -class CloseView(nextcord.ui.View): - def __init__(self) -> None: - super().__init__(timeout=None) - - @nextcord.ui.button( - label="Acknowledge", - style=nextcord.ButtonStyle.blurple, - custom_id="closeview:close", - ) - async def close(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): - if isinstance(inter.channel, nextcord.TextChannel): - await inter.channel.send("Closing ticket...") - category = inter.guild.get_channel(CLOSED_CATEGORY) - await inter.channel.edit(category=category) - # TODO: remove person from ticket - - class QuickResponse(nextcord.ui.Modal): def __init__(self, person, message) -> None: super().__init__( @@ -131,7 +115,7 @@ async def callback(self, inter: nextcord.Interaction) -> None: await new_channel.send( content=f"<@{id}>", embed=em, - view=CloseView(), + view=CloseView(CLOSED_CATEGORY), ) await new_channel.set_permissions( person, send_messages=False, read_messages=True diff --git a/views/close.py b/views/close.py new file mode 100644 index 0000000..f1335e2 --- /dev/null +++ b/views/close.py @@ -0,0 +1,19 @@ +import nextcord + + +class CloseView(nextcord.ui.View): + def __init__(self, closed_category=None) -> None: + super().__init__(timeout=None) + self.closed_category = closed_category + + @nextcord.ui.button( + label="Acknowledge", + style=nextcord.ButtonStyle.blurple, + custom_id="closeview:close", + ) + async def close(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): + if isinstance(inter.channel, nextcord.TextChannel): + await inter.channel.send("Closing ticket...") + category = inter.guild.get_channel(self.closed_category) + await inter.channel.edit(category=category) + # TODO: remove person from ticket