Skip to content

Commit

Permalink
send username as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Techbot121 authored and Meta Construct committed Jun 13, 2024
1 parent 9e269a0 commit adc1daf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions app/services/gamebridge/payloads/ChatPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ export default class ChatPayload extends Payload {
reply = await msg.fetchReference();
}

let nickname = msg.author.username;
const username = msg.author.username;
let nickname = "";
try {
const author = await msg.guild?.members.fetch(msg.author.id);
if (author && author.nickname && author.nickname.length > 0) {
nickname = `${author.nickname} (${nickname})`;
nickname = author.nickname;
}
} catch {} // dont care

const avatar = msg.author.avatarURL({ forceStatic: true });
const avatar = msg.author.avatarURL();

const payload: ChatResponse = {
user: {
id: msg.author.id,
username: username,
nick: nickname,
color: msg.member?.displayColor ?? 0,
avatar_url: avatar ?? msg.author.defaultAvatarURL,
Expand Down
9 changes: 5 additions & 4 deletions app/services/gamebridge/payloads/structures/ChatResponse.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
export default interface ChatResponse {
user: {
avatar_url: string;
color: number;
id: string;
nick: string;
color: number;
avatar_url: string;
username: string;
};
replied_message?: {
msgID: string;
content: string;
ingameName: string;
msgID: string;
};
msgID: string;
content: string;
msgID: string;
}

0 comments on commit adc1daf

Please sign in to comment.