-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenView.py
61 lines (55 loc) · 2.71 KB
/
OpenView.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
# Copyright (C) 2024 QWERTZexe
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
######################################################
# IMPORTS
import discord
from PartnerInfo import PartnerInfo
from TicketInfo import TicketInfo
import utilities
# OPENVIEW.PY
class OpenView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Apply for Partner", emoji="🤝", style=discord.ButtonStyle.blurple, custom_id="partner_button")
async def partner_button(self, interaction: discord.Interaction, button: discord.Button):
# Check for existing tickets
TICKET_CTGRY_ID = utilities.get_config("TICKET_CTGRY_ID")
category = await interaction.client.fetch_channel(TICKET_CTGRY_ID)
user_tickets = []
for channel in category.channels:
try:
if str(interaction.user.id) in channel.topic:
user_tickets.append(channel)
except:
pass
if len(user_tickets) >= 2:
await interaction.response.send_message("You already have 2 open tickets. Please close an existing ticket before opening a new one.", ephemeral=True)
else:
await interaction.response.send_modal(PartnerInfo())
@discord.ui.button(label="Open a support ticket", emoji="🎫", style=discord.ButtonStyle.gray, custom_id="ticket_button")
async def ticket_button(self, interaction: discord.Interaction, button: discord.Button):
# Check for existing tickets
TICKET_CTGRY_ID = utilities.get_config("TICKET_CTGRY_ID")
category = await interaction.client.fetch_channel(TICKET_CTGRY_ID)
user_tickets = []
for channel in category.channels:
try:
if str(interaction.user.id) in channel.topic:
user_tickets.append(channel)
except:
pass
if len(user_tickets) >= 2:
await interaction.response.send_message("You already have 2 open tickets. Please close an existing ticket before opening a new one.", ephemeral=True)
else:
await interaction.response.send_modal(TicketInfo())