1
1
mirror of https://github.com/ARK-Unity/ark-unity.git synced 2024-07-06 20:50:11 +02:00

fix: support-tickets add option to not inherit category permissions

This commit is contained in:
Théo LUDWIG 2024-06-09 18:21:29 +02:00
parent 0c2770dbdf
commit 5f8fe7bef1
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
3 changed files with 26 additions and 15 deletions

View File

@ -133,6 +133,7 @@ export const SUPPORT_TICKETS_CATEGORIES: SupportTicketsCategories = new Map([
{
title: "Server/Cluster Promotion",
description: "Want to promote your server/cluster?",
shouldInheritCategoryPermissions: false,
id: SUPPORT_TICKETS_PROMOTION_ID,
emoji: "🌐",
textInputs: [

View File

@ -20,6 +20,7 @@ export const SUPPORT_TICKETS_SELECT_MENU_ID = "support-tickets-select-menu-id"
export interface SupportTicketCategory {
title: string
description: string
shouldInheritCategoryPermissions?: boolean
id: string
emoji: string
textInputs: TextInputBuilder[]

View File

@ -1,15 +1,16 @@
import type { OverwriteResolvable } from "discord.js"
import {
GuildMember,
Guild,
ChannelType,
userMention,
EmbedBuilder,
channelMention,
codeBlock,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
CategoryChannel,
ChannelType,
EmbedBuilder,
Guild,
GuildMember,
channelMention,
codeBlock,
userMention,
} from "discord.js"
import type { HandleInteractionCreateSupportTickets } from "#src/support-tickets/configuration.js"
@ -66,17 +67,25 @@ export const handleSupportTicketsModalSubmit: HandleInteractionCreateSupportTick
return false
}
const { shouldInheritCategoryPermissions = true, textInputs } = category
const permissionOverwrites: OverwriteResolvable[] = [
{
allow: ["ViewChannel", "SendMessages"],
id: interaction.member.user.id,
},
]
if (shouldInheritCategoryPermissions) {
permissionOverwrites.push(
...channelCategory.permissionOverwrites.valueOf().toJSON(),
)
}
const channel = await interaction.guild.channels.create({
name: channelName,
type: ChannelType.GuildText,
parent: DISCORD_SUPPORT_TICKETS_OPEN_CATEGORY_ID,
permissionOverwrites: [
{
allow: ["ViewChannel", "SendMessages"],
id: interaction.member.user.id,
},
...channelCategory.permissionOverwrites.valueOf().toJSON(),
],
permissionOverwrites,
})
await channel.send({
content: userMention(interaction.member.id),
@ -92,7 +101,7 @@ To close this ticket react with the button below.
.setImage(supportTicketsImageURL)
.setColor([56, 142, 60]),
new EmbedBuilder().setDescription(
category.textInputs
textInputs
.map((textInput, index) => {
const label = textInput.data.label ?? `Field ${index}`
const value = interaction.fields.getTextInputValue(