Isaac (eartharoid) f572523e4b Replace emoji names with unicode characters
...to fix emoji in emebds for web archives
2020-11-20 23:50:08 +00:00

71 lines
2.0 KiB
JavaScript

/**
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*/
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'topic',
description: 'Edit a ticket topic',
usage: '<topic>',
aliases: ['edit'],
example: 'topic need help error',
args: true,
async execute(client, message, args, {config, Ticket}) {
const guild = client.guilds.cache.get(config.guild);
let ticket = await Ticket.findOne({
where: {
channel: message.channel.id
}
});
if (!ticket) {
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle('❌ **This isn\'t a ticket channel**')
.setDescription('Use this command in the ticket channel you want to close, or mention the channel.')
.addField('Usage', `\`${config.prefix}${this.name} ${this.usage}\`\n`)
.addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`)
.setFooter(guild.name, guild.iconURL())
);
}
let topic = args.join(' ');
if (topic.length > 256) {
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle('❌ **Description too long**')
.setDescription('Please limit your ticket topic to less than 256 characters. A short sentence will do.')
.setFooter(guild.name, guild.iconURL())
);
}
message.channel.setTopic(`<@${ticket.creator}> | ` + topic);
Ticket.update({
topic: topic
}, {
where: {
channel: message.channel.id
}
});
message.channel.send(
new MessageEmbed()
.setColor(config.colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle('✅ **Ticket updated**')
.setDescription('The topic has been changed.')
.setFooter(client.user.username, client.user.displayAvatarURL())
);
}
};