Я делаю свою тикет систему, но я не понял как сделать ограничение на тикеты. Вот код:
import disnake from disnake.ext import commands
class Ticket(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def ticketik(self, ctx): embed = disnake.Embed( title="Создать тикет", description="Нажмите на кнопку ниже если хотите создать тикет.", color=disnake.Colour.yellow(), ) await ctx.send( embed=embed, components=[ disnake.ui.Button(label="? Создать тикет", style=disnake.ButtonStyle.success, custom_id="create"), ], )
@commands.Cog.listener("on_button_click") async def help_listen(self, inter: disnake.MessageInteraction): if inter.component.custom_id not in ["create"]: return
if inter.component.custom_id == "create": r1: disnake.Role = inter.guild.get_role(1251811925633798154) ID = 1251807421228253204 category = disnake.utils.get(inter.guild.categories, id=ID) for ch in category.text_channels: if ch.topic == f'{inter.user.id} NOT': await inter.followup.send(f"У вас уже есть тикет в {0}".format(ch.mention), ephemeral=True) return overwrites = { inter.guild.default_role: disnake.PermissionOverwrite(read_messages=False), r1: disnake.PermissionOverwrite(view_channel=False, read_messages=False, send_messages=True, manage_messages=True), inter.user: disnake.PermissionOverwrite(view_channel=False, read_messages=True, send_messages=True), inter.guild.me: disnake.PermissionOverwrite(view_channel=False, read_messages=False, send_messages=True), } self.channel = await category.create_text_channel(name=f"Тикет-{inter.user.name}", overwrites=overwrites) embed = disnake.Embed( title=f"Тикет участника {inter.user.name}", description="В скором времени администрация ответит на ваш вопрос.", color=disnake.Colour.yellow(), ) await self.channel.send( embed=embed, components=[ disnake.ui.Button(label="Удалить тикет", style=disnake.ButtonStyle.red, custom_id="delete"), ], ) await inter.send(f"Ваш тикет был успешно создан: {self.channel.mention}", ephemeral=True)
@commands.Cog.listener("on_button_click") async def help_listener(self, inter: disnake.MessageInteraction): if inter.component.custom_id not in ["delete"]: return
if inter.component.custom_id == "delete": await self.channel.delete()