mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 17:23:08 +02:00
feat: add /transfer
command
This commit is contained in:
parent
26ab229c97
commit
4b40f2cdbd
@ -1,5 +1,10 @@
|
|||||||
const { SlashCommand } = require('@eartharoid/dbf');
|
const { SlashCommand } = require('@eartharoid/dbf');
|
||||||
const { ApplicationCommandOptionType } = require('discord.js');
|
const {
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
EmbedBuilder,
|
||||||
|
} = require('discord.js');
|
||||||
|
const Cryptr = require('cryptr');
|
||||||
|
const { decrypt } = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||||
|
|
||||||
module.exports = class TransferSlashCommand extends SlashCommand {
|
module.exports = class TransferSlashCommand extends SlashCommand {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@ -26,5 +31,46 @@ module.exports = class TransferSlashCommand extends SlashCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(interaction) {}
|
/**
|
||||||
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
|
*/
|
||||||
|
async run(interaction) {
|
||||||
|
/** @type {import("client")} */
|
||||||
|
const client = this.client;
|
||||||
|
|
||||||
|
await interaction.deferReply({ ephemeral: false });
|
||||||
|
|
||||||
|
const member = interaction.options.getMember('member', true);
|
||||||
|
|
||||||
|
let ticket = await client.prisma.ticket.findUnique({ where: { id: interaction.channel.id } });
|
||||||
|
const from = ticket.createdById;
|
||||||
|
|
||||||
|
ticket = await client.prisma.ticket.update({
|
||||||
|
data: {
|
||||||
|
createdBy: {
|
||||||
|
connectOrCreate: {
|
||||||
|
create: { id: member.id },
|
||||||
|
where: { id: member.id },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: { guild: true },
|
||||||
|
where: { id: interaction.channel.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
await interaction.channel.setTopic(`${member.toString}${ticket.topic?.length > 0 ? ` | ${decrypt(ticket.topic)}` : ''}`);
|
||||||
|
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setColor(ticket.guild.primaryColour)
|
||||||
|
.setDescription(client.i18n.getMessage(ticket.guild.locale, 'commands.slash.transfer.transferred', {
|
||||||
|
from: `<@${from}>`,
|
||||||
|
to: member.toString(),
|
||||||
|
user: interaction.user.toString(),
|
||||||
|
})),
|
||||||
|
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -220,6 +220,7 @@ commands:
|
|||||||
member:
|
member:
|
||||||
description: The member to transfer ownership to
|
description: The member to transfer ownership to
|
||||||
name: member
|
name: member
|
||||||
|
transferred: 📨 {user} has transferred this ticket from {from} to {to}.
|
||||||
user:
|
user:
|
||||||
create:
|
create:
|
||||||
name: Create a ticket for user
|
name: Create a ticket for user
|
||||||
|
Loading…
Reference in New Issue
Block a user