fix: anyone being able to close any ticket

This commit is contained in:
Isaac 2021-10-07 11:09:53 +01:00
parent 0fcaace8ca
commit c3ac408733
No known key found for this signature in database
GPG Key ID: 87B9B6BD04EB7534
2 changed files with 30 additions and 1 deletions

View File

@ -52,6 +52,19 @@ module.exports = class CloseCommand extends Command {
const time = interaction.options.getString(default_i18n('commands.close.options.time.name'));
if (time) {
if (!await this.client.utils.isStaff(interaction.member)) {
return await interaction.reply({
embeds: [
new MessageEmbed()
.setColor(settings.error_colour)
.setTitle(i18n('commands.close.response.no_permission.title'))
.setDescription(i18n('commands.close.response.no_permission.description'))
.setFooter(settings.footer, interaction.guild.iconURL())
],
ephemeral: true
});
}
let period;
try {
period = ms(time);
@ -176,7 +189,6 @@ module.exports = class CloseCommand extends Command {
});
}
} else {
let t_row;
if (ticket) {
t_row = await this.client.tickets.resolve(ticket, interaction.guild.id);
@ -208,6 +220,19 @@ module.exports = class CloseCommand extends Command {
}
}
if (t_row.creator !== interaction.member.id && !await this.client.utils.isStaff(interaction.member)) {
return await interaction.reply({
embeds: [
new MessageEmbed()
.setColor(settings.error_colour)
.setTitle(i18n('commands.close.response.no_permission.title'))
.setDescription(i18n('commands.close.response.no_permission.description'))
.setFooter(settings.footer, interaction.guild.iconURL())
],
ephemeral: true
});
}
await interaction.reply({
components: [
new MessageActionRow()

View File

@ -179,6 +179,10 @@
"description": "The time period provided could not be parsed.",
"title": "❌ Invalid input"
},
"no_permission": {
"description": "You are not a staff member or the ticket creator.",
"title": "❌ Insufficient permission"
},
"no_tickets": {
"description": "There are no tickets which have been inactive for this time period.",
"title": "❌ No tickets to close"