Skip to content

Commit

Permalink
move CloseView to views
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 17, 2023
1 parent 252883c commit 897e716
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
20 changes: 2 additions & 18 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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__(
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions views/close.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 897e716

Please sign in to comment.