mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-22 15:53:08 +02:00
fix: keep priority when moving (closes #467)
This commit is contained in:
parent
8a8bc2bebe
commit
34b5090575
@ -2,7 +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 { isStaff } = require('../../lib/users');
|
const { isStaff } = require('../../lib/users');
|
||||||
|
const { getEmoji } = require('./priority');
|
||||||
module.exports = class MoveSlashCommand extends SlashCommand {
|
module.exports = class MoveSlashCommand extends SlashCommand {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
const name = 'move';
|
const name = 'move';
|
||||||
@ -129,7 +129,7 @@ module.exports = class MoveSlashCommand extends SlashCommand {
|
|||||||
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
|
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
|
||||||
await interaction.channel.edit({
|
await interaction.channel.edit({
|
||||||
lockPermissions: false,
|
lockPermissions: false,
|
||||||
name: channelName,
|
name: ticket.priority ? getEmoji(ticket.priority) + channelName : channelName,
|
||||||
parent: discordCategory,
|
parent: discordCategory,
|
||||||
permissionOverwrites: [
|
permissionOverwrites: [
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,15 @@ const ExtendedEmbedBuilder = require('../../lib/embed');
|
|||||||
const { logTicketEvent } = require('../../lib/logging');
|
const { logTicketEvent } = require('../../lib/logging');
|
||||||
const { isStaff } = require('../../lib/users');
|
const { isStaff } = require('../../lib/users');
|
||||||
|
|
||||||
|
const getEmoji = priority => {
|
||||||
|
const emojis = {
|
||||||
|
'HIGH': '🔴',
|
||||||
|
'MEDIUM': '🟠',
|
||||||
|
'LOW': '🟢', // eslint-disable-line sort-keys
|
||||||
|
};
|
||||||
|
return emojis[priority];
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = class PrioritySlashCommand extends SlashCommand {
|
module.exports = class PrioritySlashCommand extends SlashCommand {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
const name = 'priority';
|
const name = 'priority';
|
||||||
@ -37,25 +46,6 @@ module.exports = class PrioritySlashCommand extends SlashCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getEmoji(priority) {
|
|
||||||
let emoji;
|
|
||||||
switch (priority) {
|
|
||||||
case 'HIGH': {
|
|
||||||
emoji = '🔴';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'MEDIUM': {
|
|
||||||
emoji = '🟠';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'LOW': {
|
|
||||||
emoji = '🟢';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return emoji;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
@ -103,8 +93,8 @@ module.exports = class PrioritySlashCommand extends SlashCommand {
|
|||||||
|
|
||||||
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(getEmoji(ticket.priority), getEmoji(priority));
|
||||||
else name = this.getEmoji(priority) + name;
|
else name = getEmoji(priority) + name;
|
||||||
await interaction.channel.setName(name);
|
await interaction.channel.setName(name);
|
||||||
|
|
||||||
// don't reassign ticket because the original is used below
|
// don't reassign ticket because the original is used below
|
||||||
@ -139,4 +129,6 @@ module.exports = class PrioritySlashCommand extends SlashCommand {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.getEmoji = getEmoji;
|
||||||
|
Loading…
Reference in New Issue
Block a user