mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +02:00
Add pin command
This commit is contained in:
parent
9d46abcbb3
commit
10ef6bb617
@ -1,4 +1,5 @@
|
||||
const { MessageCommand } = require('@eartharoid/dbf');
|
||||
const ExtendedEmbedBuilder = require('../../lib/embed');
|
||||
|
||||
module.exports = class PinMessageCommand extends MessageCommand {
|
||||
constructor(client, options) {
|
||||
@ -13,5 +14,62 @@ module.exports = class PinMessageCommand extends MessageCommand {
|
||||
});
|
||||
}
|
||||
|
||||
async run(interaction) { }
|
||||
/**
|
||||
* @param {import("discord.js").MessageContextMenuCommandInteraction} interaction
|
||||
*/
|
||||
async run(interaction) {
|
||||
/** @type {import("client")} */
|
||||
const client = this.client;
|
||||
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const ticket = await client.prisma.ticket.findUnique({
|
||||
include: { guild: true },
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
|
||||
if (!ticket) {
|
||||
const settings = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } });
|
||||
const getMessage = client.i18n.getLocale(settings.locale);
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new ExtendedEmbedBuilder({
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
text: settings.footer,
|
||||
})
|
||||
.setColor(settings.errorColour)
|
||||
.setTitle(getMessage('commands.message.pin.not_ticket.title'))
|
||||
.setDescription(getMessage('commands.message.pin.not_ticket.description')),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
||||
|
||||
if (!interaction.targetMessage.pinnable) {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new ExtendedEmbedBuilder({
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
text: ticket.guild.footer,
|
||||
})
|
||||
.setColor(ticket.guild.errorColour)
|
||||
.setTitle(getMessage('commands.message.pin.not_pinnable.title'))
|
||||
.setDescription(getMessage('commands.message.pin.not_pinnable.description')),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
await interaction.targetMessage.pin();
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new ExtendedEmbedBuilder({
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
text: ticket.guild.footer,
|
||||
})
|
||||
.setColor(ticket.guild.successColour)
|
||||
.setTitle(getMessage('commands.message.pin.pinned.title'))
|
||||
.setDescription(getMessage('commands.message.pin.pinned.description')),
|
||||
],
|
||||
});
|
||||
}
|
||||
};
|
@ -23,6 +23,17 @@ commands:
|
||||
name: Create a ticket from message
|
||||
pin:
|
||||
name: Pin message
|
||||
not_pinnable:
|
||||
description: |
|
||||
This message can't be pinned.
|
||||
Please ask an administrator to check the bot's permissions.
|
||||
title: ❌ Error
|
||||
not_ticket:
|
||||
description: You can only pin messages in tickets.
|
||||
title: ❌ This isn't a ticket channel
|
||||
pinned:
|
||||
description: The message has been pinned.
|
||||
title: ✅ Pinned message
|
||||
slash:
|
||||
add:
|
||||
description: Add a member to a ticket
|
||||
|
Loading…
Reference in New Issue
Block a user