mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-22 15:53: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);
|
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;
|
const from = ticket.createdById;
|
||||||
|
|
||||||
ticket = await client.prisma.ticket.update({
|
await client.prisma.ticket.update({
|
||||||
data: {
|
data: {
|
||||||
createdBy: {
|
createdBy: {
|
||||||
connectOrCreate: {
|
connectOrCreate: {
|
||||||
@ -54,10 +60,19 @@ module.exports = class TransferSlashCommand extends SlashCommand {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
include: { guild: true },
|
|
||||||
where: { id: interaction.channel.id },
|
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({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
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(
|
await interaction.channel.permissionOverwrites.edit(
|
||||||
member,
|
member,
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user