mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03: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:
|
misc:
|
||||||
no_categories:
|
no_categories:
|
||||||
description: No ticket categories have been configured.
|
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');
|
} = require('discord.js');
|
||||||
const emoji = require('node-emoji');
|
const emoji = require('node-emoji');
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
|
||||||
module.exports = class TicketManager {
|
module.exports = class TicketManager {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@ -35,10 +36,30 @@ module.exports = class TicketManager {
|
|||||||
},
|
},
|
||||||
where: { id: Number(categoryId) },
|
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'));
|
this.client.keyv.set(cacheKey, category, ms('5m'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: if member !required roles -> stop
|
// TODO: if member !required roles -> stop
|
||||||
|
|
||||||
// TODO: if discordCategory has 50 channels -> stop
|
// TODO: if discordCategory has 50 channels -> stop
|
||||||
@ -51,7 +72,8 @@ module.exports = class TicketManager {
|
|||||||
|
|
||||||
// TODO: if 10s ratelimit -> stop
|
// 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) {
|
if (category.questions.length >= 1) {
|
||||||
await interaction.showModal(
|
await interaction.showModal(
|
||||||
|
Loading…
Reference in New Issue
Block a user