From 1c0dae1e44411fae8eff5de247427f19c0b286d4 Mon Sep 17 00:00:00 2001 From: dev-737 <73829355+dev-737@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:00:20 +0000 Subject: [PATCH] fix(network): fix nickname setting not working on network --- src/managers/NetworkManager.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/managers/NetworkManager.ts b/src/managers/NetworkManager.ts index 44eb2ab5..ca74c45c 100644 --- a/src/managers/NetworkManager.ts +++ b/src/managers/NetworkManager.ts @@ -133,12 +133,15 @@ export default class NetworkManager extends Factory { } } + const username = settings.has('UseNicknames') + ? message.member?.displayName || message.author.displayName + : message.author.username; + // embeds for the normal mode - const { embed, censoredEmbed } = this.buildNetworkEmbed(message, { + const { embed, censoredEmbed } = this.buildNetworkEmbed(message, username, { attachmentURL, referredContent, embedCol: (isNetworkMessage.embedColor as HexColorString) ?? undefined, - useNicknames: settings.has('UseNicknames'), }); const sendResult = allConnections.map(async (connection) => { @@ -206,7 +209,7 @@ export default class NetworkManager extends Factory { (connection.profFilter ? message.censoredContent : message.content) + // append the attachment url if there is one `${attachment ? `\n${attachmentURL}` : ''}`, - username: `@${message.author.username} • ${message.guild}`, + username: `@${username} • ${message.guild}`, avatarURL: message.author.displayAvatarURL(), threadId: connection.parentId ? connection.channelId : undefined, allowedMentions: { parse: [] }, @@ -453,20 +456,18 @@ export default class NetworkManager extends Factory { */ public buildNetworkEmbed( message: NetworkMessage, + username: string, opts?: { attachmentURL?: string | null; embedCol?: HexColorString; referredContent?: string; - useNicknames?: boolean; }, ): { embed: EmbedBuilder; censoredEmbed: EmbedBuilder } { const formattedReply = opts?.referredContent?.replaceAll('\n', '\n> '); const embed = new EmbedBuilder() .setAuthor({ - name: opts?.useNicknames - ? message.member?.displayName || message.author.displayName - : message.author.username, + name: username, iconURL: message.author.displayAvatarURL(), }) .setDescription(