mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-06 02:01:26 +03:00
"topic" command
This commit is contained in:
@@ -24,5 +24,58 @@ module.exports = class TopicCommand extends Command {
|
||||
async execute(message, args) {
|
||||
let settings = await message.guild.settings;
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
let t_row = await this.client.db.models.Ticket.findOne({
|
||||
where: {
|
||||
id: message.channel.id
|
||||
}
|
||||
});
|
||||
|
||||
if (!t_row) {
|
||||
return await message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.error_colour)
|
||||
.setTitle(i18n('commands.topic.response.not_a_ticket.title'))
|
||||
.setDescription(i18n('commands.topic.response.not_a_ticket.description'))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
}
|
||||
|
||||
await t_row.update({
|
||||
topic: this.client.cryptr.encrypt(args)
|
||||
});
|
||||
|
||||
let member = await message.guild.members.fetch(t_row.creator);
|
||||
/* await */message.channel.setTopic(`${member} | ${args}`, { reason: 'User updated ticket topic' });
|
||||
|
||||
let cat_row = await this.client.db.models.Category.findOne({
|
||||
where: {
|
||||
id: t_row.category
|
||||
}
|
||||
});
|
||||
let description = cat_row.opening_message
|
||||
.replace(/{+\s?(user)?name\s?}+/gi, member.displayName)
|
||||
.replace(/{+\s?(tag|ping|mention)?\s?}+/gi, member.user.toString());
|
||||
let opening_message = await message.channel.messages.fetch(t_row.opening_message);
|
||||
|
||||
await opening_message.edit(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.colour)
|
||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||
.setDescription(description)
|
||||
.addField(i18n('ticket.opening_message.fields.topic'), args)
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
|
||||
await message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.success_colour)
|
||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||
.setTitle(i18n('commands.topic.response.changed.title'))
|
||||
.setDescription(i18n('commands.topic.response.changed.description'))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
|
||||
this.client.log.info(`${message.author.tag} changed the topic of ${message.channel.id}`);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user