Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 74d879b

Browse files
authored
fix: fix undefined username for compact mode replies
This happens if message is replied to before it is stored in interchat's database
1 parent f02d49f commit 74d879b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/managers/EventManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { addReaction, updateReactions } from '../scripts/reaction/actions.js';
3333
import { checkBlacklists } from '../scripts/reaction/helpers.js';
3434
import { CustomID } from '../utils/CustomID.js';
3535
import SuperClient from '../core/Client.js';
36-
import broadcastMessage from '../scripts/network/broadcastMessage.js';
36+
import sendBroadcast from '../scripts/network/sendBroadcast.js';
3737

3838
export default abstract class EventManager {
3939
@GatewayEvent('ready')
@@ -274,7 +274,7 @@ export default abstract class EventManager {
274274

275275
const { dbReferrence, referredAuthor } = await getReferredMsgData(referredMessage);
276276

277-
const sendResult = broadcastMessage(message, hub, hubConnections, settings, {
277+
const sendResult = sendBroadcast(message, hub, hubConnections, settings, {
278278
attachmentURL,
279279
dbReferrence,
280280
referredAuthor,

src/scripts/network/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const trimAndCensorBannedWebhookWords = (content: string) =>
118118

119119
export const generateJumpButton = (
120120
replyMsg: broadcastedMessages,
121-
referredAuthorUsername: string | undefined,
121+
referredAuthorUsername: string,
122122
serverId: string,
123123
) => {
124124
// create a jump to reply button

src/scripts/network/broadcastMessage.ts renamed to src/scripts/network/sendBroadcast.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export default (
5858
(msg) => msg.channelId === connection.channelId,
5959
);
6060

61-
const jumpButton = reply
62-
? generateJumpButton(reply, opts.referredAuthor?.username, connection.serverId)
61+
const jumpButton = reply && opts.referredAuthor
62+
? generateJumpButton(reply, opts.referredAuthor.username, connection.serverId)
6363
: undefined;
6464

6565
// embed format
@@ -79,7 +79,7 @@ export default (
7979
// preview embed for the message being replied to
8080
const replyEmbed = replyContent
8181
? new EmbedBuilder({
82-
description: replyContent,
82+
description: replyContent ?? 'Unknown User',
8383
author: {
8484
name: `${opts.referredAuthor?.username?.slice(0, 30)}`,
8585
icon_url: opts.referredAuthor?.displayAvatarURL(),

0 commit comments

Comments
 (0)