From d88524e8cf3a61e3399e049f615fa5d28d66693f Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Wed, 30 Aug 2023 17:01:29 -0600 Subject: [PATCH] ShowMeYourName: Fix username being wrong on slash commands (#1690) Co-authored-by: V --- src/plugins/showMeYourName/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index 7123fc63..4ccaeea8 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -21,13 +21,14 @@ import "./styles.css"; import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { Message } from "discord-types/general"; +import { Message, User } from "discord-types/general"; interface UsernameProps { author: { nick: string; }; message: Message; withMentionPrefix?: boolean; isRepliedMessage: boolean; + userOverride?: User; } const settings = definePluginSettings({ @@ -67,11 +68,12 @@ export default definePlugin({ ], settings, - renderUsername: ({ author, message, isRepliedMessage, withMentionPrefix }: UsernameProps) => { + renderUsername: ({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => { try { - let { username } = message.author; + const user = userOverride ?? message.author; + let { username } = user; if (settings.store.displayNames) - username = (message.author as any).globalName || username; + username = (user as any).globalName || username; const { nick } = author; const prefix = withMentionPrefix ? "@" : "";