Implement required roles

This commit is contained in:
Isaac 2022-08-09 00:21:15 +01:00
parent 53f00b715b
commit 913465a165
No known key found for this signature in database
GPG Key ID: F4EAABEB0FFCC06A
2 changed files with 21 additions and 3 deletions

View File

@ -161,7 +161,7 @@ log:
delete: deleted delete: deleted
update: updated update: updated
ticket: ticket:
description: '{user} {verb} ticket' description: '{user} {verb} a ticket'
ticket: Ticket ticket: Ticket
title: Ticket {verb} title: Ticket {verb}
verb: verb:
@ -178,6 +178,9 @@ misc:
blocked: blocked:
description: You are not allowed to create tickets. description: You are not allowed to create tickets.
title: ❌ Blocked title: ❌ Blocked
missing_roles:
description: You do not have the roles required to be able to create a ticket in this category.
title: ❌ Insufficient roles
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

View File

@ -112,10 +112,25 @@ module.exports = class TicketManager {
ephemeral: true, ephemeral: true,
}); });
} }
} }
// TODO: if member !required roles -> stop if (category.requiredRoles.length !== 0) {
const missing = category.requiredRoles.some(r => !member.roles.cache.has(r));
if (missing) {
return await interaction.reply({
embeds: [
new ExtendedEmbedBuilder({
iconURL: interaction.guild.iconURL(),
text: category.guild.footer,
})
.setColor(category.guild.errorColour)
.setTitle(getMessage('misc.missing_roles.title'))
.setDescription(getMessage('misc.missing_roles.description')),
],
ephemeral: true,
});
}
}
// TODO: if discordCategory has 50 channels -> stop // TODO: if discordCategory has 50 channels -> stop