fix(modmail): validate categories exist before opening ticket + clean stale tickets
All checks were successful
deploy / deploy (push) Successful in 22s
All checks were successful
deploy / deploy (push) Successful in 22s
This commit is contained in:
parent
eec6b2bb9b
commit
d43bc24453
1 changed files with 17 additions and 1 deletions
|
|
@ -31,7 +31,11 @@ class CategorySelect(discord.ui.Select):
|
|||
try:
|
||||
category_key = self.values[0]
|
||||
categories = cfg.get_categories()
|
||||
cat = categories.get(category_key, {})
|
||||
cat = categories.get(category_key)
|
||||
if not cat:
|
||||
await interaction.response.send_message("Cette categorie n'existe plus.", ephemeral=True)
|
||||
return
|
||||
|
||||
data = cfg.get_config()
|
||||
guild = interaction.client.get_guild(data.get("guild_id"))
|
||||
if not guild:
|
||||
|
|
@ -73,6 +77,9 @@ class TicketModal(discord.ui.Modal, title="Nouveau Ticket"):
|
|||
await interaction.response.defer(ephemeral=True)
|
||||
bot = interaction.client
|
||||
data = cfg.get_config()
|
||||
if self.category_key not in cfg.get_categories():
|
||||
await interaction.followup.send("La categorie n'existe plus. Reessayez.", ephemeral=True)
|
||||
return
|
||||
guild = bot.get_guild(data.get("guild_id"))
|
||||
if not guild:
|
||||
await interaction.followup.send("Erreur serveur.", ephemeral=True)
|
||||
|
|
@ -422,6 +429,15 @@ class ModMail(commands.Cog):
|
|||
await self._send_to_ticket(ch, message.author, message)
|
||||
return
|
||||
|
||||
categories = cfg.get_categories()
|
||||
if not categories:
|
||||
with contextlib.suppress(discord.HTTPException):
|
||||
await message.author.send(
|
||||
"Le systeme de tickets n'est pas encore configure. "
|
||||
"Un administrateur doit d'abord configurer les categories."
|
||||
)
|
||||
return
|
||||
|
||||
await self._send_ticket_creation_panel(message)
|
||||
|
||||
async def _send_ticket_creation_panel(self, message: discord.Message):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue