Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow administrators to open a ticket #20

Merged
merged 2 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 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,34 @@ 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.",
}
),
});
}

await channel.send({
content: (
Expand All @@ -193,16 +215,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