mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 17:23:08 +02:00
fix: check roles for staff-only commands
This commit is contained in:
parent
b14f057dd0
commit
daadb5fe85
@ -1,6 +1,7 @@
|
|||||||
const { SlashCommand } = require('@eartharoid/dbf');
|
const { SlashCommand } = require('@eartharoid/dbf');
|
||||||
const { ApplicationCommandOptionType } = require('discord.js');
|
const { ApplicationCommandOptionType } = require('discord.js');
|
||||||
const ExtendedEmbedBuilder = require('../../lib/embed');
|
const ExtendedEmbedBuilder = require('../../lib/embed');
|
||||||
|
const { isStaff } = require('../../lib/users');
|
||||||
|
|
||||||
module.exports = class MoveSlashCommand extends SlashCommand {
|
module.exports = class MoveSlashCommand extends SlashCommand {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@ -62,10 +63,25 @@ module.exports = class MoveSlashCommand extends SlashCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
||||||
|
|
||||||
|
if (!(await isStaff(interaction.guild, interaction.user.id))) { // if user is not staff
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new ExtendedEmbedBuilder({
|
||||||
|
iconURL: interaction.guild.iconURL(),
|
||||||
|
text: ticket.guild.footer,
|
||||||
|
})
|
||||||
|
.setColor(ticket.guild.errorColour)
|
||||||
|
.setTitle(getMessage('commands.slash.move.not_staff.title'))
|
||||||
|
.setDescription(getMessage('commands.slash.move.not_staff.description')),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const creator = await interaction.guild.members.fetch(ticket.createdById);
|
const creator = await interaction.guild.members.fetch(ticket.createdById);
|
||||||
const newCategory = await client.prisma.category.findUnique({ where: { id: interaction.options.getInteger('category', true) } });
|
const newCategory = await client.prisma.category.findUnique({ where: { id: interaction.options.getInteger('category', true) } });
|
||||||
const discordCategory = await interaction.guild.channels.fetch(newCategory.discordCategory);
|
const discordCategory = await interaction.guild.channels.fetch(newCategory.discordCategory);
|
||||||
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
|
||||||
|
|
||||||
if (discordCategory.children.cache.size === 50) {
|
if (discordCategory.children.cache.size === 50) {
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
|
@ -2,6 +2,7 @@ const { SlashCommand } = require('@eartharoid/dbf');
|
|||||||
const { ApplicationCommandOptionType } = require('discord.js');
|
const { ApplicationCommandOptionType } = require('discord.js');
|
||||||
const ExtendedEmbedBuilder = require('../../lib/embed');
|
const ExtendedEmbedBuilder = require('../../lib/embed');
|
||||||
const { logTicketEvent } = require('../../lib/logging');
|
const { logTicketEvent } = require('../../lib/logging');
|
||||||
|
const { isStaff } = require('../../lib/users');
|
||||||
|
|
||||||
module.exports = class PrioritySlashCommand extends SlashCommand {
|
module.exports = class PrioritySlashCommand extends SlashCommand {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@ -86,6 +87,20 @@ module.exports = class PrioritySlashCommand extends SlashCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(await isStaff(interaction.guild, interaction.user.id))) { // if user is not staff
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new ExtendedEmbedBuilder({
|
||||||
|
iconURL: interaction.guild.iconURL(),
|
||||||
|
text: ticket.guild.footer,
|
||||||
|
})
|
||||||
|
.setColor(ticket.guild.errorColour)
|
||||||
|
.setTitle(getMessage('commands.slash.move.not_staff.title'))
|
||||||
|
.setDescription(getMessage('commands.slash.move.not_staff.description')),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const priority = interaction.options.getString('priority', true);
|
const priority = interaction.options.getString('priority', true);
|
||||||
let name = interaction.channel.name;
|
let name = interaction.channel.name;
|
||||||
if (ticket.priority) name = name.replace(this.getEmoji(ticket.priority), this.getEmoji(priority));
|
if (ticket.priority) name = name.replace(this.getEmoji(ticket.priority), this.getEmoji(priority));
|
||||||
|
@ -64,6 +64,9 @@ commands:
|
|||||||
claim:
|
claim:
|
||||||
description: Claim a ticket
|
description: Claim a ticket
|
||||||
name: claim
|
name: claim
|
||||||
|
not_staff:
|
||||||
|
description: Only staff members can claim tickets.
|
||||||
|
title: ❌ Error
|
||||||
close:
|
close:
|
||||||
description: Request a ticket to be closed
|
description: Request a ticket to be closed
|
||||||
invalid_time:
|
invalid_time:
|
||||||
@ -126,6 +129,9 @@ commands:
|
|||||||
description: Move a ticket to another category
|
description: Move a ticket to another category
|
||||||
moved: 🗃️ {by} has moved this ticket from **{from}** to **{to}**.
|
moved: 🗃️ {by} has moved this ticket from **{from}** to **{to}**.
|
||||||
name: move
|
name: move
|
||||||
|
not_staff:
|
||||||
|
description: Only staff members can move tickets.
|
||||||
|
title: ❌ Error
|
||||||
options:
|
options:
|
||||||
category:
|
category:
|
||||||
description: The category to move the ticket to
|
description: The category to move the ticket to
|
||||||
@ -140,6 +146,9 @@ commands:
|
|||||||
priority:
|
priority:
|
||||||
description: Set the priority of a ticket
|
description: Set the priority of a ticket
|
||||||
name: priority
|
name: priority
|
||||||
|
not_staff:
|
||||||
|
description: Only staff members can change the priority of tickets.
|
||||||
|
title: ❌ Error
|
||||||
options:
|
options:
|
||||||
priority:
|
priority:
|
||||||
choices:
|
choices:
|
||||||
@ -158,7 +167,7 @@ commands:
|
|||||||
description: Remove a member from a ticket
|
description: Remove a member from a ticket
|
||||||
name: remove
|
name: remove
|
||||||
not_staff:
|
not_staff:
|
||||||
description: Only staff members can removed members from others' tickets.
|
description: Only staff members can remove members from others' tickets.
|
||||||
title: ❌ Error
|
title: ❌ Error
|
||||||
options:
|
options:
|
||||||
member:
|
member:
|
||||||
|
@ -698,6 +698,20 @@ module.exports = class TicketManager {
|
|||||||
});
|
});
|
||||||
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
|
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
|
||||||
|
|
||||||
|
if (!(await isStaff(interaction.guild, interaction.user.id))) { // if user is not staff
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new ExtendedEmbedBuilder({
|
||||||
|
iconURL: interaction.guild.iconURL(),
|
||||||
|
text: ticket.guild.footer,
|
||||||
|
})
|
||||||
|
.setColor(ticket.guild.errorColour)
|
||||||
|
.setTitle(getMessage('commands.slash.claim.not_staff.title'))
|
||||||
|
.setDescription(getMessage('commands.slash.claim.not_staff.description')),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
interaction.channel.permissionOverwrites.edit(interaction.user, { 'ViewChannel': true }, `Ticket claimed by ${interaction.user.tag}`),
|
interaction.channel.permissionOverwrites.edit(interaction.user, { 'ViewChannel': true }, `Ticket claimed by ${interaction.user.tag}`),
|
||||||
...ticket.category.staffRoles.map(role => interaction.channel.permissionOverwrites.edit(role, { 'ViewChannel': false }, `Ticket claimed by ${interaction.user.tag}`)),
|
...ticket.category.staffRoles.map(role => interaction.channel.permissionOverwrites.edit(role, { 'ViewChannel': false }, `Ticket claimed by ${interaction.user.tag}`)),
|
||||||
@ -784,6 +798,20 @@ module.exports = class TicketManager {
|
|||||||
});
|
});
|
||||||
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
|
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
|
||||||
|
|
||||||
|
if (!(await isStaff(interaction.guild, interaction.user.id))) { // if user is not staff
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new ExtendedEmbedBuilder({
|
||||||
|
iconURL: interaction.guild.iconURL(),
|
||||||
|
text: ticket.guild.footer,
|
||||||
|
})
|
||||||
|
.setColor(ticket.guild.errorColour)
|
||||||
|
.setTitle(getMessage('commands.slash.claim.not_staff.title'))
|
||||||
|
.setDescription(getMessage('commands.slash.claim.not_staff.description')),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
interaction.channel.permissionOverwrites.delete(interaction.user, `Ticket released by ${interaction.user.tag}`),
|
interaction.channel.permissionOverwrites.delete(interaction.user, `Ticket released by ${interaction.user.tag}`),
|
||||||
...ticket.category.staffRoles.map(role => interaction.channel.permissionOverwrites.edit(role, { 'ViewChannel': true }, `Ticket released by ${interaction.user.tag}`)),
|
...ticket.category.staffRoles.map(role => interaction.channel.permissionOverwrites.edit(role, { 'ViewChannel': true }, `Ticket released by ${interaction.user.tag}`)),
|
||||||
|
Loading…
Reference in New Issue
Block a user