mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 04:13:08 +02:00
fix: edit channel name when transferring (closes #470)
This commit is contained in:
parent
59a6358b37
commit
77e5b45aa8
@ -42,10 +42,16 @@ module.exports = class TransferSlashCommand extends SlashCommand {
|
||||
|
||||
const member = interaction.options.getMember('member', true);
|
||||
|
||||
let ticket = await client.prisma.ticket.findUnique({ where: { id: interaction.channel.id } });
|
||||
const ticket = await client.prisma.ticket.findUnique({
|
||||
include: {
|
||||
category: true,
|
||||
guild: true,
|
||||
},
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
const from = ticket.createdById;
|
||||
|
||||
ticket = await client.prisma.ticket.update({
|
||||
await client.prisma.ticket.update({
|
||||
data: {
|
||||
createdBy: {
|
||||
connectOrCreate: {
|
||||
@ -54,10 +60,19 @@ module.exports = class TransferSlashCommand extends SlashCommand {
|
||||
},
|
||||
},
|
||||
},
|
||||
include: { guild: true },
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
|
||||
const channelName = ticket.category.channelName
|
||||
.replace(/{+\s?(user)?name\s?}+/gi, member.user.username)
|
||||
.replace(/{+\s?(nick|display)(name)?\s?}+/gi, member.displayName)
|
||||
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
|
||||
|
||||
await interaction.channel.edit({
|
||||
name: channelName,
|
||||
topic: `${member.toString()}${ticket.topic?.length > 0 ? ` | ${decrypt(ticket.topic)}` : ''}`,
|
||||
});
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@ -71,8 +86,6 @@ module.exports = class TransferSlashCommand extends SlashCommand {
|
||||
],
|
||||
});
|
||||
|
||||
await interaction.channel.setTopic(`${member.toString()}${ticket.topic?.length > 0 ? ` | ${decrypt(ticket.topic)}` : ''}`);
|
||||
|
||||
await interaction.channel.permissionOverwrites.edit(
|
||||
member,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user