mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-24 09:09:12 -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 ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { RelationshipStore } from "@webpack/common";
|
||||||
import { Message, User } from "discord-types/general";
|
import { Message, User } from "discord-types/general";
|
||||||
|
|
||||||
interface UsernameProps {
|
interface UsernameProps {
|
||||||
|
@ -40,6 +41,11 @@ const settings = definePluginSettings({
|
||||||
default: false,
|
default: false,
|
||||||
description: "Also apply functionality to reply previews",
|
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({
|
export default definePlugin({
|
||||||
|
@ -60,9 +66,12 @@ export default definePlugin({
|
||||||
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
||||||
try {
|
try {
|
||||||
const user = userOverride ?? message.author;
|
const user = userOverride ?? message.author;
|
||||||
|
const friendName = RelationshipStore.getNickname(user.id);
|
||||||
let { username } = user;
|
let { username } = user;
|
||||||
if (settings.store.displayNames)
|
if (settings.store.displayNames)
|
||||||
username = (user as any).globalName || username;
|
username = (user as any).globalName || username;
|
||||||
|
if (settings.store.preferFriend)
|
||||||
|
username = friendName ?? username;
|
||||||
|
|
||||||
const { nick } = author;
|
const { nick } = author;
|
||||||
const prefix = withMentionPrefix ? "@" : "";
|
const prefix = withMentionPrefix ? "@" : "";
|
||||||
|
|
Loading…
Add table
Reference in a new issue