diff --git a/src/discord/utils/techHelp.ts b/src/discord/utils/techHelp.ts index a9835743..c5e21535 100644 --- a/src/discord/utils/techHelp.ts +++ b/src/discord/utils/techHelp.ts @@ -6,6 +6,7 @@ import { TextChannel, ButtonBuilder, GuildMember, + User, ThreadChannel, ModalSubmitInteraction, Colors, @@ -96,15 +97,20 @@ export async function techHelpClick(interaction:ButtonInteraction) { const modalInput = i.fields.getTextInputValue(`${issueType}IssueInput`); // log.debug(F, `modalInput: ${modalInput}!`); - // // Get the actor - const actor = i.user; + // Get the actor + const actor = (i.member ?? i.user) as GuildMember | User; + + // Get the actors name. + const targetName = (actor as GuildMember | null)?.displayName + ?? (actor as User | null)?.username + ?? '[Deleted Discord Account]'; // Create a new thread in channel const ticketThread = await (i.channel as TextChannel).threads.create({ - name: `🧡│${actor.username}'s ${issueType} issue!`, + name: `🧡│${targetName}'s ${issueType} issue!`, autoArchiveDuration: 1440, type: ChannelType.PrivateThread as AllowedThreadTypeForTextChannel, - reason: `${actor.username} submitted a(n) ${issueType} issue`, + reason: `${targetName} submitted a(n) ${issueType} issue`, invitable: false, }); // log.debug(F, `Created meta-thread ${ticketThread.id}`); @@ -119,11 +125,11 @@ export async function techHelpClick(interaction:ButtonInteraction) { const techHelpButtons = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId(`techHelpOwn~${issueType}~${actor.id}`) + .setCustomId(`techHelpOwn~${issueType}~${actor?.id}`) .setLabel('Own this issue!') .setStyle(ButtonStyle.Primary), new ButtonBuilder() - .setCustomId(`techHelpClose~${issueType}~${actor.id}`) + .setCustomId(`techHelpClose~${issueType}~${actor?.id}`) .setLabel('Close this issue!') .setStyle(ButtonStyle.Success), );