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

Use display name for mod ticket thread names #875

Merged
merged 2 commits into from
Nov 11, 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
18 changes: 12 additions & 6 deletions src/discord/utils/techHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TextChannel,
ButtonBuilder,
GuildMember,
User,
ThreadChannel,
ModalSubmitInteraction,
Colors,
Expand Down Expand Up @@ -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}`);
Expand All @@ -119,11 +125,11 @@ export async function techHelpClick(interaction:ButtonInteraction) {
const techHelpButtons = new ActionRowBuilder<ButtonBuilder>()
.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),
);
Expand Down
Loading