|
13 | 13 | * @module events/interactionCreate
|
14 | 14 | */
|
15 | 15 |
|
16 |
| -import { Events, MessageFlags, Interaction, CommandInteraction, ModalSubmitInteraction, EmbedBuilder } from 'discord.js'; |
| 16 | +import { Events, MessageFlags, ChannelType, Interaction, CommandInteraction, ModalSubmitInteraction, EmbedBuilder } from 'discord.js'; |
17 | 17 | import { createTicket, bindTicketWithThread } from '../services/unthread';
|
18 | 18 | import { LogEngine } from '../config/logger';
|
19 | 19 | import { setKey } from '../utils/memory';
|
@@ -127,10 +127,21 @@ async function handleSupportModal(interaction: ModalSubmitInteraction): Promise<
|
127 | 127 | throw new Error('This command must be used in a text channel that supports threads');
|
128 | 128 | }
|
129 | 129 |
|
130 |
| - thread = await interaction.channel.threads.create({ |
131 |
| - name: `ticket-#${ticketObj.friendlyId}`, |
132 |
| - reason: 'Unthread Ticket', |
133 |
| - }); |
| 130 | + // Create thread based on channel type to satisfy TypeScript's type constraints |
| 131 | + if (interaction.channel.type === ChannelType.GuildAnnouncement) { |
| 132 | + thread = await interaction.channel.threads.create({ |
| 133 | + name: `ticket-#${ticketObj.friendlyId}`, |
| 134 | + type: ChannelType.AnnouncementThread, |
| 135 | + reason: 'Unthread Ticket', |
| 136 | + }); |
| 137 | + } |
| 138 | + else { |
| 139 | + thread = await interaction.channel.threads.create({ |
| 140 | + name: `ticket-#${ticketObj.friendlyId}`, |
| 141 | + type: ChannelType.PrivateThread, |
| 142 | + reason: 'Unthread Ticket', |
| 143 | + }); |
| 144 | + } |
134 | 145 |
|
135 | 146 | if (!thread) {
|
136 | 147 | throw new Error('Failed to create Discord thread');
|
|
0 commit comments