Skip to content

Commit

Permalink
fix(network): fix nickname setting not working on network
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 authored Dec 21, 2023
1 parent 30f9d2f commit 1c0dae1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/managers/NetworkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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: [] },
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 1c0dae1

Please sign in to comment.