Skip to content

Commit

Permalink
add new reason to ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlauer-Hax committed Oct 27, 2023
1 parent e83f6fb commit d691647
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions interactions.ts
Expand Up @@ -106,23 +106,6 @@ export async function handleInteraction(interaction: Interaction) {
const ticket_user_reason = interaction.fields.getTextInputValue("ticket_reason");
const dbuser = await findUser(interaction.user.id);
const ticketname = `ticket-${interaction.user.id}`;
const possibleChannel = interaction.guild?.channels.cache.find(ch => ch.name === ticketname) as TextChannel;
if (possibleChannel) {
await possibleChannel.permissionOverwrites.create(interaction.user.id, {
"ViewChannel": true
});
await interaction.reply({
content: `> You already have a ticket here: ${possibleChannel}`,
ephemeral: true,
});
return;
}
const ch = await interaction.guild!.channels.create({
name: ticketname,
type: ChannelType.GuildText,
topic: `ticket of ${interaction.user.tag}`,
parent: "1081347349462405221",
});

const fields = [
{
Expand Down Expand Up @@ -152,19 +135,41 @@ export async function handleInteraction(interaction: Interaction) {
})
embed.setTimestamp(new Date(new Date().toLocaleString('en-US', { timeZone: login[ 2 ] ?? "UTC" })))
}
const btnrow = new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
.setCustomId(`close_ticket`)
.setStyle(ButtonStyle.Danger)
.setLabel(`Close Ticket`),
]);
const possibleChannel = interaction.guild?.channels.cache.find(ch => ch.name === ticketname) as TextChannel;
if (possibleChannel) {
await possibleChannel.permissionOverwrites.create(interaction.user.id, {
"ViewChannel": true
});
await possibleChannel.send({
content: `${interaction.member} || <@&1120392307087261787>`,
embeds: [ embed ],
components: [ btnrow ],
});
await interaction.reply({
content: `> You already have a ticket here: ${possibleChannel}`,
ephemeral: true,
});
return;
}
const ch = await interaction.guild!.channels.create({
name: ticketname,
type: ChannelType.GuildText,
topic: `ticket of ${interaction.user.tag}`,
parent: "1081347349462405221",
});

setTimeout(() => {
ch.permissionOverwrites.create(interaction.user.id, {
"ViewChannel": true
});
}, 5000);

const btnrow = new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
.setCustomId(`close_ticket`)
.setStyle(ButtonStyle.Danger)
.setLabel(`Close Ticket`),
]);
await ch.send({
content: `${interaction.member} || <@&1120392307087261787>`,
embeds: [ embed ],
Expand Down

0 comments on commit d691647

Please sign in to comment.