-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
72 lines (59 loc) · 2.77 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import disnake
class confirm_button(disnake.ui.View):
"""Ticket close confirmation button"""
def __init__(self, db):
super().__init__(timeout=30)
self.db = db
@disnake.ui.button(
label="Confirm",
style=disnake.ButtonStyle.danger,
custom_id="confirm_close",
emoji="⚠️"
)
async def close(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
await interaction.response.defer(ephemeral=True)
ticket_collection = self.db['tickets']
ticket_doc = await ticket_collection.find_one(
{"channel_id": str(interaction.channel.id)})
if ticket_doc is None:
return await interaction.send(f"This channel is not a ticket channel.")
if ticket_doc['status'] == 'closed':
return await interaction.send(f"This ticket is already closed.")
ticket_collection.update_one({"channel_id": str(interaction.channel.id)}, {
"$set": {"status": "closed"}})
await interaction.send(f"This ticket has been closed by {interaction.author.mention}.")
return await interaction.channel.delete(reason=f"Closed by {interaction.author.name}.")
@disnake.ui.button(
label="Cancel",
style=disnake.ButtonStyle.gray,
custom_id="cancel_close",
)
async def cancel_close(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
return await interaction.send("OK! Cancelled", ephemeral=True)
class close_button(disnake.ui.View):
"""Close button for ticket channel"""
def __init__(self):
super().__init__(timeout=None)
@disnake.ui.button(
label="Close",
style=disnake.ButtonStyle.danger,
custom_id="close_ticket",
emoji="🔒"
)
async def close(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
pass
class raise_ticket_select(disnake.ui.View):
"""Raise ticket from panel"""
def __init__(self):
super().__init__(timeout=None)
@disnake.ui.select(
options=[disnake.SelectOption(label="General Category", value="general", description="Use this category for problems related to the discord."),
disnake.SelectOption(label="Paid Category", value="paid",
description="Use this category for problems related to the paid Hosting or if you want to buy a new server."),
disnake.SelectOption(label="Panel Category", value="panel", description="Use this category for problems related to the panel.")],
custom_id="raiseticket",
max_values=1,
min_values=1
)
async def _raise_ticket_select(self, select: disnake.ui.Select, interaction: disnake.MessageInteraction):
pass