Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 18, 2023
1 parent 7e264f7 commit 658c5c3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions cogs/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@


class CloseRequest(nextcord.ui.View):
def __init__(self, inter: nextcord.Interaction):
def __init__(self, inter: nextcord.Interaction, old_channel: nextcord.TextChannel):
super().__init__(timeout=60)
self.inter = inter
self.old_channel = old_channel

@nextcord.ui.button(label="☑️ Accept & Close", style=nextcord.ButtonStyle.green)
async def accept(self, button: nextcord.ui.Button, inter: nextcord.Interaction):
if isinstance(inter.channel, nextcord.TextChannel):
category = nextcord.utils.get(inter.guild.categories, id=CLOSED_CATEGORY)
await self.inter.channel.send("Closing ticket...")
await self.inter.channel.edit(category=category)
await self.inter.channel.set_permissions(
self.inter.user, send_messages=False, read_messages=False
)
await self.inter.channel.send("Ticket closed!")
await self.inter.channel.delete()

@nextcord.ui.button(label="❌ Deny & Keep Open", style=nextcord.ButtonStyle.gray)
async def deny(self, button: nextcord.ui.Button, inter: nextcord.Interaction):
if isinstance(inter.channel, nextcord.TextChannel):
category = nextcord.utils.get(
inter.guild.categories, id=self.old_channel.category_id
)
await self.inter.channel.edit(category=category)
await inter.channel.send("Request denied!")


Expand Down Expand Up @@ -73,16 +74,16 @@ async def close_ticket(self, inter: nextcord.Interaction):

@slash_command(name="closereq", description="request to close ticket")
async def close_request(self, inter: nextcord.Interaction):
if inter.channel.category_id == CLOSED_CATEGORY:
await inter.send("This channel is already closed!", ephemeral=True)
return

em = nextcord.Embed()
em.color = CLOSE_REQUEST
em.title = "Ticket Close Request"
em.description = f"<@{inter.user.id}> has requested to close this ticket.\n\nPlease accept or deny this request using the buttons below."

await inter.channel.send(embed=em, view=CloseRequest(inter=inter))
category = nextcord.utils.get(inter.guild.categories, id=CLOSED_CATEGORY)
await inter.channel.edit(category=category)
await inter.channel.send(
embed=em, view=CloseRequest(inter=inter, old_channel=inter.channel)
)


def setup(bot: Bot) -> None:
Expand Down

0 comments on commit 658c5c3

Please sign in to comment.