mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 12:23:09 +02:00
Make sure category hasn't been deleted
This commit is contained in:
parent
0a10d91f8d
commit
efe7ede041
@ -162,4 +162,7 @@ modals:
|
||||
misc:
|
||||
no_categories:
|
||||
description: No ticket categories have been configured.
|
||||
title: ❌ There are no ticket categories
|
||||
title: ❌ There are no ticket categories
|
||||
unknown_category:
|
||||
description: Please try a different category.
|
||||
title: ❌ That ticket category doesn't exist
|
@ -8,6 +8,7 @@ const {
|
||||
} = require('discord.js');
|
||||
const emoji = require('node-emoji');
|
||||
const ms = require('ms');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
module.exports = class TicketManager {
|
||||
constructor(client) {
|
||||
@ -35,10 +36,30 @@ module.exports = class TicketManager {
|
||||
},
|
||||
where: { id: Number(categoryId) },
|
||||
});
|
||||
if (!category) {
|
||||
let settings;
|
||||
if (interaction.guild) {
|
||||
settings = await this.client.prisma.guild.findUnique({ where: { id: interaction.guild.id } });
|
||||
} else {
|
||||
settings = {
|
||||
errorColour: 'Red',
|
||||
locale: 'en-GB',
|
||||
};
|
||||
}
|
||||
const getMessage = this.client.i18n.getLocale(settings.locale);
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setColor(settings.errorColour)
|
||||
.setTitle(getMessage('misc.unknown_category.title'))
|
||||
.setDescription(getMessage('misc.unknown_category.description'))
|
||||
.setFooter(settings.footer),
|
||||
],
|
||||
});
|
||||
}
|
||||
this.client.keyv.set(cacheKey, category, ms('5m'));
|
||||
}
|
||||
|
||||
|
||||
// TODO: if member !required roles -> stop
|
||||
|
||||
// TODO: if discordCategory has 50 channels -> stop
|
||||
@ -51,7 +72,8 @@ module.exports = class TicketManager {
|
||||
|
||||
// TODO: if 10s ratelimit -> stop
|
||||
|
||||
const getMessage = this.client.i18n.getLocale(category.guild.locale);
|
||||
|
||||
const getMessage = this.client.i18n.getLocale(category.guild.locale);
|
||||
|
||||
if (category.questions.length >= 1) {
|
||||
await interaction.showModal(
|
||||
|
Loading…
Reference in New Issue
Block a user