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
15
packages/discord-types/enums/channel.ts
Normal file
15
packages/discord-types/enums/channel.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
export const enum ChannelType {
|
||||||
|
GUILD_TEXT = 0,
|
||||||
|
DM = 1,
|
||||||
|
GUILD_VOICE = 2,
|
||||||
|
GROUP_DM = 3,
|
||||||
|
GUILD_CATEGORY = 4,
|
||||||
|
GUILD_ANNOUNCEMENT = 5,
|
||||||
|
ANNOUNCEMENT_THREAD = 10,
|
||||||
|
PUBLIC_THREAD = 11,
|
||||||
|
PRIVATE_THREAD = 12,
|
||||||
|
GUILD_STAGE_VOICE = 13,
|
||||||
|
GUILD_DIRECTORY = 14,
|
||||||
|
GUILD_FORUM = 15,
|
||||||
|
GUILD_MEDIA = 16
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export * from "./commands";
|
export * from "./commands";
|
||||||
export * from "./messages";
|
export * from "./messages";
|
||||||
|
export * from "./channel";
|
||||||
|
|
@ -53,7 +53,7 @@ const settings = definePluginSettings({
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoReplyMention",
|
name: "NoReplyMention",
|
||||||
description: "Disables reply pings by default",
|
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,
|
settings,
|
||||||
|
|
||||||
shouldMention(message: Message, isHoldingShift: boolean) {
|
shouldMention(message: Message, isHoldingShift: boolean) {
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,9 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { MessageJSON } from "@vencord/discord-types";
|
import { MessageJSON } from "@vencord/discord-types";
|
||||||
|
import { ChannelType } from "@vencord/discord-types/enums";
|
||||||
import { ChannelStore, ReadStateStore, UserStore } from "@webpack/common";
|
import { ChannelStore, ReadStateStore, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
const enum ChannelType {
|
|
||||||
DM = 1,
|
|
||||||
GROUP_DM = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
channelToAffect: {
|
channelToAffect: {
|
||||||
type: OptionType.SELECT,
|
type: OptionType.SELECT,
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||||
|
import { ChannelType } from "@vencord/discord-types/enums";
|
||||||
import { UserUtils } from "@webpack/common";
|
import { UserUtils } from "@webpack/common";
|
||||||
|
|
||||||
import settings from "./settings";
|
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";
|
import { deleteGroup, deleteGuild, getGroup, getGuild, GuildAvailabilityStore, notify } from "./utils";
|
||||||
|
|
||||||
let manuallyRemovedFriend: string | undefined;
|
let manuallyRemovedFriend: string | undefined;
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,6 @@ export interface SimpleGuild {
|
||||||
iconURL?: string;
|
iconURL?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum ChannelType {
|
|
||||||
GROUP_DM = 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
export const enum RelationshipType {
|
export const enum RelationshipType {
|
||||||
FRIEND = 1,
|
FRIEND = 1,
|
||||||
BLOCKED = 2,
|
BLOCKED = 2,
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,12 @@ import { DataStore, Notices } from "@api/index";
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||||
import { FluxStore } from "@vencord/discord-types";
|
import { FluxStore } from "@vencord/discord-types";
|
||||||
|
import { ChannelType } from "@vencord/discord-types/enums";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStoreLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
||||||
|
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
import { RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
||||||
|
|
||||||
export const GuildAvailabilityStore = findStoreLazy("GuildAvailabilityStore") as FluxStore & {
|
export const GuildAvailabilityStore = findStoreLazy("GuildAvailabilityStore") as FluxStore & {
|
||||||
totalGuilds: number;
|
totalGuilds: number;
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,12 @@ 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 { Message, User } from "@vencord/discord-types";
|
import { Channel, Message, User } from "@vencord/discord-types";
|
||||||
|
import { RelationshipStore } from "@webpack/common";
|
||||||
|
|
||||||
interface UsernameProps {
|
interface UsernameProps {
|
||||||
author: { nick: string; };
|
author: { nick: string; authorId: string; };
|
||||||
|
channel: Channel;
|
||||||
message: Message;
|
message: Message;
|
||||||
withMentionPrefix?: boolean;
|
withMentionPrefix?: boolean;
|
||||||
isRepliedMessage: boolean;
|
isRepliedMessage: boolean;
|
||||||
|
|
@ -30,6 +32,15 @@ const settings = definePluginSettings({
|
||||||
{ label: "Username only", value: "user" },
|
{ 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: {
|
displayNames: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Use display names in place of usernames",
|
description: "Use display names in place of usernames",
|
||||||
|
|
@ -45,7 +56,7 @@ const settings = definePluginSettings({
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ShowMeYourName",
|
name: "ShowMeYourName",
|
||||||
description: "Display usernames next to nicks, or no nicks at all",
|
description: "Display usernames next to nicks, or no nicks at all",
|
||||||
authors: [Devs.Rini, Devs.TheKodeToad],
|
authors: [Devs.Rini, Devs.TheKodeToad, Devs.rae],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: '="SYSTEM_TAG"',
|
find: '="SYSTEM_TAG"',
|
||||||
|
|
@ -58,23 +69,39 @@ export default definePlugin({
|
||||||
],
|
],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
renderUsername: ErrorBoundary.wrap(({ author, channel, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
||||||
try {
|
try {
|
||||||
|
const { mode, friendNicknames, displayNames, inReplies } = settings.store;
|
||||||
|
|
||||||
const user = userOverride ?? message.author;
|
const user = userOverride ?? message.author;
|
||||||
let { username } = user;
|
let { username } = user;
|
||||||
if (settings.store.displayNames)
|
|
||||||
|
if (displayNames)
|
||||||
username = user.globalName || username;
|
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 ? "@" : "";
|
const prefix = withMentionPrefix ? "@" : "";
|
||||||
|
|
||||||
if (isRepliedMessage && !settings.store.inReplies || username.toLowerCase() === nick.toLowerCase())
|
if (isRepliedMessage && !inReplies || username.toLowerCase() === nick.toLowerCase())
|
||||||
return <>{prefix}{nick}</>;
|
return <>{prefix}{nick}</>;
|
||||||
|
|
||||||
if (settings.store.mode === "user-nick")
|
if (mode === "user-nick")
|
||||||
return <>{prefix}{username} <span className="vc-smyn-suffix">{nick}</span></>;
|
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}{nick} <span className="vc-smyn-suffix">{username}</span></>;
|
||||||
|
|
||||||
return <>{prefix}{username}</>;
|
return <>{prefix}{username}</>;
|
||||||
|
|
|
||||||
|
|
@ -197,9 +197,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "sunnie",
|
name: "sunnie",
|
||||||
id: 406028027768733696n
|
id: 406028027768733696n
|
||||||
},
|
},
|
||||||
axyie: {
|
rae: {
|
||||||
name: "'ax",
|
name: "rae",
|
||||||
id: 929877747151548487n,
|
id: 1398136199503282277n
|
||||||
},
|
},
|
||||||
pointy: {
|
pointy: {
|
||||||
name: "pointy",
|
name: "pointy",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue