Skip to content

Commit

Permalink
Allow administrators to open a ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
imxeno committed May 20, 2024
1 parent 0fac3b6 commit 5cdd2cc
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions apps/bot/src/modules/tickets/commands/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,35 @@ export class TicketCommand extends Subcommand {
name: `ticket-${localIdCounter}-${interaction.user.username}`,
});

// Add permissions for the creator of the ticket
await channel.permissionOverwrites.create(interaction.user, {
ViewChannel: true,
SendMessages: true,
ReadMessageHistory: true,
});
try {
// Add permissions for the creator of the ticket
await channel.permissionOverwrites.create(interaction.user, {
ViewChannel: true,
SendMessages: true,
ReadMessageHistory: true,
});

await interaction.editReply({
content: localizedReply(
interaction,
`Created a ticket: <#${channel.id}>.`,
{
pl: `Utworzono zgłoszenie: <#${channel.id}>.`,
}
),
});
} catch {
await interaction.editReply({
content: localizedReply(
interaction,
"Created a ticket: <#{channelId}>, but failed to set permissions for the ticket channel. Either you have superpowers or something went wrong - in that case contact the server administrator.",
{
pl: "Utworzono zgłoszenie: <#{channelId}>, ale nie udało mi się nadać Ci uprawnień dla kanału zgłoszenia. Albo masz supermoce albo coś poszło nie tak - w tym drugim przypadku skontaktuj się z administratorem serwera.",
}
),
});
return;
}

await channel.send({
content: (
Expand All @@ -193,16 +216,6 @@ export class TicketCommand extends Subcommand {
.replaceAll("{userId}", interaction.user.id || "")
.replaceAll("{reason}", reason || ""),
});

await interaction.editReply({
content: localizedReply(
interaction,
`Created a ticket: <#${channel.id}>.`,
{
pl: `Utworzono zgłoszenie: <#${channel.id}>.`,
}
),
});
}

public async chatInputClose(
Expand Down

0 comments on commit 5cdd2cc

Please sign in to comment.