From 172d1b471e3c2d3f42efe95a035a675b3b64dec0 Mon Sep 17 00:00:00 2001 From: salixor <salixor@pm.me> Date: Thu, 26 Dec 2024 00:25:44 +0100 Subject: [PATCH] Fix another Promise (not caught because of missing type) --- src/matrixeventprocessor.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts index cfc829a..b720f90 100644 --- a/src/matrixeventprocessor.ts +++ b/src/matrixeventprocessor.ts @@ -495,7 +495,7 @@ export class MatrixEventProcessor { displayname: string, avatar_url: string|undefined }) { let displayName = sender; - let avatarUrl; + let avatarUrl: string | undefined = undefined; // Are they a discord user. if (this.bridge.isNamespacedUser(sender)) { @@ -517,22 +517,21 @@ export class MatrixEventProcessor { // Let it fall through. } - if (profile) { - if (profile.displayname && - profile.displayname.length >= MIN_NAME_LENGTH && - profile.displayname.length <= MAX_NAME_LENGTH) { - displayName = profile.displayname; - } + if (profile?.displayname && + profile.displayname.length >= MIN_NAME_LENGTH && + profile.displayname.length <= MAX_NAME_LENGTH) { + displayName = profile.displayname; + } - if (profile.avatar_url) { - avatarUrl = this.bridge.botClient.mxcToHttpThumbnail( - profile.avatar_url, - DISCORD_AVATAR_WIDTH, - DISCORD_AVATAR_HEIGHT, - "scale", - ); - } + if (profile?.avatar_url) { + avatarUrl = await this.bridge.botClient.mxcToHttpThumbnail( + profile.avatar_url, + DISCORD_AVATAR_WIDTH, + DISCORD_AVATAR_HEIGHT, + "scale", + ); } + embed.setAuthor( displayName.substring(0, MAX_NAME_LENGTH), avatarUrl, -- GitLab