PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 1 | import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, ButtonInteraction } from "discord.js"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 2 | import { tickets, toHexArray } from "../../utils/calculate.js"; |
| 3 | import client from "../../utils/client.js"; |
| 4 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
| 5 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 6 | import { getCommandMentionByName } from "../../utils/getCommandDataByName.js"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 7 | |
| 8 | function capitalize(s: string) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 9 | s = s.replace(/([A-Z])/g, " $1"); |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 10 | return s.length < 3 ? s.toUpperCase() : s[0]!.toUpperCase() + s.slice(1).toLowerCase(); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 11 | } |
| 12 | |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 13 | export default async function (interaction: CommandInteraction | ButtonInteraction) { |
PineaFan | a00db1b | 2023-01-02 15:32:54 +0000 | [diff] [blame] | 14 | if (!interaction.guild) return; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 15 | const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 16 | const config = await client.database.guilds.read(interaction.guild.id); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 17 | if (!config.tickets.enabled || !config.tickets.category) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 18 | return await interaction.reply({ |
| 19 | embeds: [ |
| 20 | new EmojiEmbed() |
| 21 | .setTitle("Tickets are disabled") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 22 | .setDescription("Please enable tickets in the configuration to use this command.") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 23 | .setFooter({ |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 24 | text: (interaction.member!.permissions as Discord.PermissionsBitField).has("ManageGuild") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 25 | ? "You can enable it by running /settings tickets" |
| 26 | : "" |
| 27 | }) |
| 28 | .setStatus("Danger") |
| 29 | .setEmoji("CONTROL.BLOCKCROSS") |
| 30 | ], |
| 31 | ephemeral: true |
| 32 | }); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 33 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 34 | let count = 0; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 35 | const targetChannel: Discord.CategoryChannel | Discord.TextChannel = (await interaction.guild.channels.fetch(config.tickets.category))! as Discord.CategoryChannel | Discord.TextChannel; |
| 36 | if (targetChannel.type === Discord.ChannelType.GuildCategory) { |
| 37 | // For channels, the topic is the user ID, then the word Active |
| 38 | const category = targetChannel as Discord.CategoryChannel; |
| 39 | category.children.cache.forEach((element) => { |
| 40 | if (!(element.type === Discord.ChannelType.GuildText)) return; |
| 41 | if (((element as Discord.TextChannel).topic ?? "").includes(`${interaction.member!.user.id}`)) { |
| 42 | if (((element as Discord.TextChannel).topic ?? "").endsWith("Active")) { count++; } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 43 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 44 | }); |
| 45 | } else { |
| 46 | // For threads, the name is the users name, id, then the word Active |
| 47 | const channel = targetChannel as Discord.TextChannel; |
| 48 | channel.threads.cache.forEach((element: Discord.ThreadChannel) => { |
| 49 | if (element.name.includes(`${interaction.member!.user.id}`)) { |
| 50 | if (element.name.endsWith("Active")) { count++; } |
| 51 | } |
| 52 | }); |
| 53 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 54 | if (count >= config.tickets.maxTickets) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 55 | return await interaction.reply({ |
| 56 | embeds: [ |
| 57 | new EmojiEmbed() |
| 58 | .setTitle("Create Ticket") |
| 59 | .setDescription( |
| 60 | `You have reached the maximum amount of tickets (${config.tickets.maxTickets}). Please close one of your active tickets before creating a new one.` |
| 61 | ) |
| 62 | .setStatus("Danger") |
| 63 | .setEmoji("CONTROL.BLOCKCROSS") |
| 64 | ], |
| 65 | ephemeral: true |
| 66 | }); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 67 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 68 | let ticketTypes: string[]; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 69 | let custom = false; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 70 | if (config.tickets.customTypes && config.tickets.useCustom) { |
| 71 | ticketTypes = config.tickets.customTypes; |
| 72 | custom = true; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 73 | } else if (config.tickets.types) ticketTypes = toHexArray(config.tickets.types, tickets); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 74 | else ticketTypes = []; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 75 | let chosenType: string | null; |
| 76 | let splitFormattedTicketTypes: ActionRowBuilder<ButtonBuilder>[] = []; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 77 | if (ticketTypes.length > 0) { |
| 78 | let formattedTicketTypes = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 79 | formattedTicketTypes = ticketTypes.map((type) => { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 80 | if (custom) { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 81 | return new ButtonBuilder().setLabel(type).setStyle(ButtonStyle.Primary).setCustomId(type); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 82 | } else { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 83 | return new ButtonBuilder() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 84 | .setLabel(capitalize(type)) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 85 | .setStyle(ButtonStyle.Primary) |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 86 | .setCustomId(type) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 87 | .setEmoji(getEmojiByName("TICKETS." + type.toString().toUpperCase(), "id")); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 88 | } |
| 89 | }); |
| 90 | for (let i = 0; i < formattedTicketTypes.length; i += 5) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 91 | splitFormattedTicketTypes.push(new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5))); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 92 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 93 | const m = await interaction.reply({ |
| 94 | embeds: [ |
| 95 | new EmojiEmbed() |
| 96 | .setTitle("Create Ticket") |
| 97 | .setDescription("Select a ticket type") |
| 98 | .setStatus("Success") |
| 99 | .setEmoji("GUILD.TICKET.OPEN") |
| 100 | ], |
| 101 | ephemeral: true, |
| 102 | fetchReply: true, |
| 103 | components: splitFormattedTicketTypes |
| 104 | }); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 105 | let component; |
| 106 | try { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 107 | component = await m.awaitMessageComponent({ |
| 108 | time: 300000, |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 109 | filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 110 | }); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 111 | } catch (e) { |
| 112 | return; |
| 113 | } |
| 114 | chosenType = component.customId; |
| 115 | splitFormattedTicketTypes = []; |
| 116 | formattedTicketTypes = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 117 | formattedTicketTypes = ticketTypes.map((type) => { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 118 | if (custom) { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 119 | return new ButtonBuilder() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 120 | .setLabel(type) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 121 | .setStyle(chosenType === type ? ButtonStyle.Success : ButtonStyle.Secondary) |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 122 | .setCustomId(type) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 123 | .setDisabled(true); |
| 124 | } else { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 125 | return new ButtonBuilder() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 126 | .setLabel(capitalize(type)) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 127 | .setStyle(chosenType === type ? ButtonStyle.Success : ButtonStyle.Secondary) |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 128 | .setCustomId(type) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 129 | .setEmoji(getEmojiByName("TICKETS." + type.toString().toUpperCase(), "id")) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 130 | .setDisabled(true); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 131 | } |
| 132 | }); |
| 133 | for (let i = 0; i < formattedTicketTypes.length; i += 5) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 134 | splitFormattedTicketTypes.push(new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5))); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 135 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 136 | component.update({ |
| 137 | embeds: [ |
| 138 | new EmojiEmbed() |
| 139 | .setTitle("Create Ticket") |
| 140 | .setDescription("Select a ticket type") |
| 141 | .setStatus("Success") |
| 142 | .setEmoji("GUILD.TICKET.OPEN") |
| 143 | ], |
| 144 | components: splitFormattedTicketTypes |
| 145 | }); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 146 | } else { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 147 | chosenType = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 148 | await interaction.reply({ |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 149 | embeds: [new EmojiEmbed().setTitle("Create Ticket").setEmoji("GUILD.TICKET.OPEN")], |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 150 | ephemeral: true, |
| 151 | components: splitFormattedTicketTypes |
| 152 | }); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 153 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 154 | let c: Discord.TextChannel | Discord.PrivateThreadChannel; |
| 155 | if (targetChannel.type === Discord.ChannelType.GuildCategory) { |
| 156 | const overwrites = [ |
| 157 | { |
| 158 | id: interaction.member, |
| 159 | allow: ["ViewChannel", "SendMessages", "AttachFiles", "AddReactions", "ReadMessageHistory"], |
| 160 | type: Discord.OverwriteType.Member |
| 161 | } |
| 162 | ] as Discord.OverwriteResolvable[]; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 163 | overwrites.push({ |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 164 | id: interaction.guild.roles.everyone, |
| 165 | deny: ["ViewChannel"], |
| 166 | type: Discord.OverwriteType.Role |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 167 | }); |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 168 | if (config.tickets.supportRole !== null) { |
| 169 | overwrites.push({ |
| 170 | id: interaction.guild.roles.cache.get(config.tickets.supportRole)!, |
| 171 | allow: ["ViewChannel", "SendMessages", "AttachFiles", "AddReactions", "ReadMessageHistory"], |
| 172 | type: Discord.OverwriteType.Role |
| 173 | }); |
| 174 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 175 | |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 176 | try { |
| 177 | c = await interaction.guild.channels.create({ |
| 178 | name: `${interaction.member!.user.username.toLowerCase()}`, |
| 179 | type: Discord.ChannelType.GuildText, |
| 180 | topic: `${interaction.member!.user.id} Active`, |
| 181 | parent: config.tickets.category, |
| 182 | nsfw: false, |
| 183 | permissionOverwrites: overwrites as Discord.OverwriteResolvable[], |
| 184 | reason: "Creating ticket" |
| 185 | }); |
| 186 | } catch (e) { |
| 187 | return await interaction.editReply({ |
| 188 | embeds: [ |
| 189 | new EmojiEmbed() |
| 190 | .setTitle("Create Ticket") |
| 191 | .setDescription("Failed to create ticket") |
| 192 | .setStatus("Danger") |
| 193 | .setEmoji("CONTROL.BLOCKCROSS") |
| 194 | ] |
| 195 | }); |
| 196 | } |
| 197 | try { |
| 198 | await c.send({ |
| 199 | content: |
| 200 | `<@${interaction.member!.user.id}>` + |
| 201 | (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : ""), |
| 202 | allowedMentions: { |
| 203 | users: [(interaction.member as Discord.GuildMember).id], |
| 204 | roles: config.tickets.supportRole !== null ? [config.tickets.supportRole] : [] |
| 205 | } |
| 206 | }); |
| 207 | let content: string | null = null; |
| 208 | if (interaction.isCommand()) { |
| 209 | content = interaction.options.get("message")?.value as string; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 210 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 211 | if (content) content = `**Message:**\n> ${content}\n`; |
| 212 | let emoji; |
| 213 | if (chosenType) { |
| 214 | emoji = custom ? "" : getEmojiByName("TICKETS." + chosenType.toUpperCase()); |
| 215 | } else { |
| 216 | emoji = ""; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 217 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 218 | await c.send({ |
| 219 | embeds: [ |
| 220 | new EmojiEmbed() |
| 221 | .setTitle("New Ticket") |
| 222 | .setDescription( |
| 223 | `Ticket created by <@${interaction.member!.user.id}>\n` + |
| 224 | `**Support type:** ${ |
| 225 | chosenType !== null ? emoji + " " + capitalize(chosenType) : "General" |
| 226 | }\n` + |
| 227 | `**Ticket ID:** \`${c.id}\`\n${content ?? ""}\n` + |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 228 | `Type ${getCommandMentionByName("ticket/close")} to close this ticket.` |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 229 | ) |
| 230 | .setStatus("Success") |
| 231 | .setEmoji("GUILD.TICKET.OPEN") |
| 232 | ], |
| 233 | components: [ |
| 234 | new ActionRowBuilder<ButtonBuilder>().addComponents([ |
| 235 | new ButtonBuilder() |
| 236 | .setLabel("Close") |
| 237 | .setStyle(ButtonStyle.Danger) |
| 238 | .setCustomId("closeticket") |
| 239 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 240 | ]) |
| 241 | ] |
| 242 | }); |
| 243 | } catch (e) { |
| 244 | return await interaction.editReply({ |
| 245 | embeds: [ |
| 246 | new EmojiEmbed() |
| 247 | .setTitle("Create Ticket") |
| 248 | .setDescription("Failed to create ticket") |
| 249 | .setStatus("Danger") |
| 250 | .setEmoji("GUILD.TICKET.CLOSE") |
| 251 | ] |
| 252 | }); |
| 253 | } |
| 254 | } else { |
| 255 | c = await targetChannel.threads.create({name: `${interaction.member!.user.username} - ${interaction.member!.user.id} - Active`, |
| 256 | autoArchiveDuration: 60 * 24 * 7, |
| 257 | type: Discord.ChannelType.PrivateThread, |
| 258 | reason: "Creating ticket" |
| 259 | }) as Discord.PrivateThreadChannel; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 260 | c.members.add(interaction.member!.user.id); |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 261 | try { |
| 262 | await c.send({ |
| 263 | content: |
| 264 | `<@${interaction.member!.user.id}>` + |
| 265 | (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : ""), |
| 266 | allowedMentions: { |
| 267 | users: [(interaction.member as Discord.GuildMember).id], |
| 268 | roles: config.tickets.supportRole !== null ? [config.tickets.supportRole] : [] |
| 269 | } |
| 270 | }); |
| 271 | let content: string | null = null; |
| 272 | if (interaction.isCommand()) { |
| 273 | content = interaction.options.get("message")?.value as string; |
| 274 | } |
| 275 | if (content) content = `**Message:**\n> ${content}\n`; |
| 276 | let emoji; |
| 277 | if (chosenType) { |
| 278 | emoji = custom ? "" : getEmojiByName("TICKETS." + chosenType.toUpperCase()); |
| 279 | } else { |
| 280 | emoji = ""; |
| 281 | } |
| 282 | await c.send({ |
| 283 | embeds: [ |
| 284 | new EmojiEmbed() |
| 285 | .setTitle("New Ticket") |
| 286 | .setDescription( |
| 287 | `Ticket created by <@${interaction.member!.user.id}>\n` + |
| 288 | `**Support type:** ${ |
| 289 | chosenType !== null ? emoji + " " + capitalize(chosenType) : "General" |
| 290 | }\n` + |
| 291 | `**Ticket ID:** \`${c.id}\`\n${content ?? ""}\n` + |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 292 | `Type ${getCommandMentionByName("ticket/close")} to close this ticket.` |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 293 | ) |
| 294 | .setStatus("Success") |
| 295 | .setEmoji("GUILD.TICKET.OPEN") |
| 296 | ], |
| 297 | components: [ |
| 298 | new ActionRowBuilder<ButtonBuilder>().addComponents([ |
| 299 | new ButtonBuilder() |
| 300 | .setLabel("Close") |
| 301 | .setStyle(ButtonStyle.Danger) |
| 302 | .setCustomId("closeticket") |
| 303 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 304 | ]) |
| 305 | ] |
| 306 | }); |
| 307 | } catch (e) { |
| 308 | return await interaction.editReply({ |
| 309 | embeds: [ |
| 310 | new EmojiEmbed() |
| 311 | .setTitle("Create Ticket") |
| 312 | .setDescription("Failed to create ticket") |
| 313 | .setStatus("Danger") |
| 314 | .setEmoji("GUILD.TICKET.CLOSE") |
| 315 | ] |
| 316 | }); |
| 317 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 318 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 319 | const data = { |
| 320 | meta: { |
| 321 | type: "ticketCreate", |
| 322 | displayName: "Ticket Created", |
| 323 | calculateType: "ticketUpdate", |
| 324 | color: NucleusColors.green, |
| 325 | emoji: "GUILD.TICKET.OPEN", |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 326 | timestamp: Date.now() |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 327 | }, |
| 328 | list: { |
| 329 | ticketFor: entry(interaction.member!.user.id, renderUser(interaction.member!.user! as Discord.User)), |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 330 | created: entry(Date.now(), renderDelta(Date.now())), |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 331 | ticketChannel: entry(c.id, renderChannel(c)) |
| 332 | }, |
| 333 | hidden: { |
| 334 | guild: interaction.guild.id |
| 335 | } |
| 336 | }; |
| 337 | log(data); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 338 | await interaction.editReply({ |
| 339 | embeds: [ |
| 340 | new EmojiEmbed() |
| 341 | .setTitle("Create Ticket") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 342 | .setDescription(`Ticket created. You can view it here: <#${c.id}>`) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 343 | .setStatus("Success") |
| 344 | .setEmoji("GUILD.TICKET.OPEN") |
| 345 | ], |
| 346 | components: splitFormattedTicketTypes |
| 347 | }); |
| 348 | } |