mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-23 16:49:24 -05:00
add preferFriends to showMeYourName (#145)
This commit is contained in:
parent
95c20fa901
commit
50166e4c31
1 changed files with 9 additions and 0 deletions
|
@ -10,6 +10,7 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { RelationshipStore } from "@webpack/common";
|
||||
import { Message, User } from "discord-types/general";
|
||||
|
||||
interface UsernameProps {
|
||||
|
@ -40,6 +41,11 @@ const settings = definePluginSettings({
|
|||
default: false,
|
||||
description: "Also apply functionality to reply previews",
|
||||
},
|
||||
preferFriend: {
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
description: "Use friend names in place of usernames (overrides Display Names option if applicable)"
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
|
@ -60,9 +66,12 @@ export default definePlugin({
|
|||
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
||||
try {
|
||||
const user = userOverride ?? message.author;
|
||||
const friendName = RelationshipStore.getNickname(user.id);
|
||||
let { username } = user;
|
||||
if (settings.store.displayNames)
|
||||
username = (user as any).globalName || username;
|
||||
if (settings.store.preferFriend)
|
||||
username = friendName ?? username;
|
||||
|
||||
const { nick } = author;
|
||||
const prefix = withMentionPrefix ? "@" : "";
|
||||
|
|
Loading…
Add table
Reference in a new issue