ShowMeYourName: support friend nicknames (#3639)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
5c69d340d9
commit
4ff3614dc0
9 changed files with 61 additions and 24 deletions
|
|
@ -53,7 +53,7 @@ const settings = definePluginSettings({
|
|||
export default definePlugin({
|
||||
name: "NoReplyMention",
|
||||
description: "Disables reply pings by default",
|
||||
authors: [Devs.DustyAngel47, Devs.axyie, Devs.pylix, Devs.outfoxxed],
|
||||
authors: [Devs.DustyAngel47, Devs.rae, Devs.pylix, Devs.outfoxxed],
|
||||
settings,
|
||||
|
||||
shouldMention(message: Message, isHoldingShift: boolean) {
|
||||
|
|
|
|||
|
|
@ -8,13 +8,9 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { MessageJSON } from "@vencord/discord-types";
|
||||
import { ChannelType } from "@vencord/discord-types/enums";
|
||||
import { ChannelStore, ReadStateStore, UserStore } from "@webpack/common";
|
||||
|
||||
const enum ChannelType {
|
||||
DM = 1,
|
||||
GROUP_DM = 3
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
channelToAffect: {
|
||||
type: OptionType.SELECT,
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
*/
|
||||
|
||||
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||
import { ChannelType } from "@vencord/discord-types/enums";
|
||||
import { UserUtils } from "@webpack/common";
|
||||
|
||||
import settings from "./settings";
|
||||
import { ChannelDelete, ChannelType, GuildDelete, RelationshipRemove, RelationshipType } from "./types";
|
||||
import { ChannelDelete, GuildDelete, RelationshipRemove, RelationshipType } from "./types";
|
||||
import { deleteGroup, deleteGuild, getGroup, getGuild, GuildAvailabilityStore, notify } from "./utils";
|
||||
|
||||
let manuallyRemovedFriend: string | undefined;
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ export interface SimpleGuild {
|
|||
iconURL?: string;
|
||||
}
|
||||
|
||||
export const enum ChannelType {
|
||||
GROUP_DM = 3,
|
||||
}
|
||||
|
||||
export const enum RelationshipType {
|
||||
FRIEND = 1,
|
||||
BLOCKED = 2,
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ import { DataStore, Notices } from "@api/index";
|
|||
import { showNotification } from "@api/Notifications";
|
||||
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||
import { FluxStore } from "@vencord/discord-types";
|
||||
import { ChannelType } from "@vencord/discord-types/enums";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
||||
|
||||
import settings from "./settings";
|
||||
import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
||||
import { RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
||||
|
||||
export const GuildAvailabilityStore = findStoreLazy("GuildAvailabilityStore") as FluxStore & {
|
||||
totalGuilds: number;
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Message, User } from "@vencord/discord-types";
|
||||
import { Channel, Message, User } from "@vencord/discord-types";
|
||||
import { RelationshipStore } from "@webpack/common";
|
||||
|
||||
interface UsernameProps {
|
||||
author: { nick: string; };
|
||||
author: { nick: string; authorId: string; };
|
||||
channel: Channel;
|
||||
message: Message;
|
||||
withMentionPrefix?: boolean;
|
||||
isRepliedMessage: boolean;
|
||||
|
|
@ -30,6 +32,15 @@ const settings = definePluginSettings({
|
|||
{ label: "Username only", value: "user" },
|
||||
],
|
||||
},
|
||||
friendNicknames: {
|
||||
type: OptionType.SELECT,
|
||||
description: "How to prioritise friend nicknames over server nicknames",
|
||||
options: [
|
||||
{ label: "Show friend nicknames only in direct messages", value: "dms", default: true },
|
||||
{ label: "Prefer friend nicknames over server nicknames", value: "always" },
|
||||
{ label: "Prefer server nicknames over friend nicknames", value: "fallback" }
|
||||
]
|
||||
},
|
||||
displayNames: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Use display names in place of usernames",
|
||||
|
|
@ -45,7 +56,7 @@ const settings = definePluginSettings({
|
|||
export default definePlugin({
|
||||
name: "ShowMeYourName",
|
||||
description: "Display usernames next to nicks, or no nicks at all",
|
||||
authors: [Devs.Rini, Devs.TheKodeToad],
|
||||
authors: [Devs.Rini, Devs.TheKodeToad, Devs.rae],
|
||||
patches: [
|
||||
{
|
||||
find: '="SYSTEM_TAG"',
|
||||
|
|
@ -58,23 +69,39 @@ export default definePlugin({
|
|||
],
|
||||
settings,
|
||||
|
||||
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
||||
renderUsername: ErrorBoundary.wrap(({ author, channel, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
||||
try {
|
||||
const { mode, friendNicknames, displayNames, inReplies } = settings.store;
|
||||
|
||||
const user = userOverride ?? message.author;
|
||||
let { username } = user;
|
||||
if (settings.store.displayNames)
|
||||
|
||||
if (displayNames)
|
||||
username = user.globalName || username;
|
||||
|
||||
const { nick } = author;
|
||||
let { nick } = author;
|
||||
|
||||
const friendNickname = RelationshipStore.getNickname(author.authorId);
|
||||
|
||||
if (friendNickname) {
|
||||
const shouldUseFriendNickname =
|
||||
friendNicknames === "always" ||
|
||||
(friendNicknames === "dms" && channel.isPrivate()) ||
|
||||
(friendNicknames === "fallback" && !nick);
|
||||
|
||||
if (shouldUseFriendNickname)
|
||||
nick = friendNickname;
|
||||
}
|
||||
|
||||
const prefix = withMentionPrefix ? "@" : "";
|
||||
|
||||
if (isRepliedMessage && !settings.store.inReplies || username.toLowerCase() === nick.toLowerCase())
|
||||
if (isRepliedMessage && !inReplies || username.toLowerCase() === nick.toLowerCase())
|
||||
return <>{prefix}{nick}</>;
|
||||
|
||||
if (settings.store.mode === "user-nick")
|
||||
if (mode === "user-nick")
|
||||
return <>{prefix}{username} <span className="vc-smyn-suffix">{nick}</span></>;
|
||||
|
||||
if (settings.store.mode === "nick-user")
|
||||
if (mode === "nick-user")
|
||||
return <>{prefix}{nick} <span className="vc-smyn-suffix">{username}</span></>;
|
||||
|
||||
return <>{prefix}{username}</>;
|
||||
|
|
|
|||
|
|
@ -197,9 +197,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "sunnie",
|
||||
id: 406028027768733696n
|
||||
},
|
||||
axyie: {
|
||||
name: "'ax",
|
||||
id: 929877747151548487n,
|
||||
rae: {
|
||||
name: "rae",
|
||||
id: 1398136199503282277n
|
||||
},
|
||||
pointy: {
|
||||
name: "pointy",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue