mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-10 23:23:04 -04:00
MoreUserTags Chat
This commit is contained in:
parent
61e75e1d89
commit
2613ec170e
17 changed files with 668 additions and 228 deletions
23
src/plugins/_api/nicknameIcons.ts
Normal file
23
src/plugins/_api/nicknameIcons.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2025 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "NicknameIconsAPI",
|
||||
description: "API to add icons to the nickname, in profiles",
|
||||
authors: [Devs.Nuckyz],
|
||||
patches: [
|
||||
{
|
||||
find: "#{intl::USER_PROFILE_LOAD_ERROR}",
|
||||
replacement: {
|
||||
match: /(\.fetchError.+?\?)null/,
|
||||
replace: (_, rest) => `${rest}Vencord.Api.NicknameIcons._renderIcons(arguments[0])`
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
|
@ -25,6 +25,7 @@ import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccesso
|
|||
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
|
||||
import { addMessageClickListener, addMessagePreEditListener, addMessagePreSendListener, removeMessageClickListener, removeMessagePreEditListener, removeMessagePreSendListener } from "@api/MessageEvents";
|
||||
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
|
||||
import { addNicknameIcon, removeNicknameIcon } from "@api/NicknameIcons";
|
||||
import { Settings, SettingsStore } from "@api/Settings";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import { Logger } from "@utils/Logger";
|
||||
|
@ -96,7 +97,7 @@ function isReporterTestable(p: Plugin, part: ReporterTestable) {
|
|||
|
||||
const pluginKeysToBind: Array<keyof PluginDef & `${"on" | "render"}${string}`> = [
|
||||
"onBeforeMessageEdit", "onBeforeMessageSend", "onMessageClick",
|
||||
"renderChatBarButton", "renderMemberListDecorator", "renderMessageAccessory", "renderMessageDecoration", "renderMessagePopoverButton"
|
||||
"renderChatBarButton", "renderMemberListDecorator", "renderNicknameIcon", "renderMessageAccessory", "renderMessageDecoration", "renderMessagePopoverButton"
|
||||
];
|
||||
|
||||
const neededApiPlugins = new Set<string>();
|
||||
|
@ -128,6 +129,7 @@ for (const p of pluginsValues) if (isPluginEnabled(p.name)) {
|
|||
if (p.onBeforeMessageEdit || p.onBeforeMessageSend || p.onMessageClick) neededApiPlugins.add("MessageEventsAPI");
|
||||
if (p.renderChatBarButton) neededApiPlugins.add("ChatInputButtonAPI");
|
||||
if (p.renderMemberListDecorator) neededApiPlugins.add("MemberListDecoratorsAPI");
|
||||
if (p.renderNicknameIcon) neededApiPlugins.add("NicknameIconsAPI");
|
||||
if (p.renderMessageAccessory) neededApiPlugins.add("MessageAccessoriesAPI");
|
||||
if (p.renderMessageDecoration) neededApiPlugins.add("MessageDecorationsAPI");
|
||||
if (p.renderMessagePopoverButton) neededApiPlugins.add("MessagePopoverAPI");
|
||||
|
@ -261,7 +263,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
|
|||
const {
|
||||
name, commands, contextMenus, managedStyle, userProfileBadge,
|
||||
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
|
||||
renderChatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
|
||||
renderChatBarButton, renderMemberListDecorator, renderNicknameIcon, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
|
||||
} = p;
|
||||
|
||||
if (p.start) {
|
||||
|
@ -313,6 +315,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
|
|||
|
||||
if (renderChatBarButton) addChatBarButton(name, renderChatBarButton);
|
||||
if (renderMemberListDecorator) addMemberListDecorator(name, renderMemberListDecorator);
|
||||
if (renderNicknameIcon) addNicknameIcon(name, renderNicknameIcon);
|
||||
if (renderMessageDecoration) addMessageDecoration(name, renderMessageDecoration);
|
||||
if (renderMessageAccessory) addMessageAccessory(name, renderMessageAccessory);
|
||||
if (renderMessagePopoverButton) addMessagePopoverButton(name, renderMessagePopoverButton);
|
||||
|
@ -324,7 +327,7 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
|
|||
const {
|
||||
name, commands, contextMenus, managedStyle, userProfileBadge,
|
||||
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
|
||||
renderChatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
|
||||
renderChatBarButton, renderMemberListDecorator, renderNicknameIcon, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
|
||||
} = p;
|
||||
|
||||
if (p.stop) {
|
||||
|
@ -374,6 +377,7 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
|
|||
|
||||
if (renderChatBarButton) removeChatBarButton(name);
|
||||
if (renderMemberListDecorator) removeMemberListDecorator(name);
|
||||
if (renderNicknameIcon) removeNicknameIcon(name);
|
||||
if (renderMessageDecoration) removeMessageDecoration(name);
|
||||
if (renderMessageAccessory) removeMessageAccessory(name);
|
||||
if (renderMessagePopoverButton) removeMessagePopoverButton(name);
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
import "./style.css";
|
||||
|
||||
import { addProfileBadge, BadgePosition, BadgeUserArgs, ProfileBadge, removeProfileBadge } from "@api/Badges";
|
||||
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
|
||||
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
|
||||
import { Settings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { addNicknameIcon, removeNicknameIcon } from "@api/NicknameIcons";
|
||||
import { definePluginSettings, migratePluginSetting } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { classes } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { filters, findStoreLazy, mapMangledModuleLazy } from "@webpack";
|
||||
import { PresenceStore, Tooltip, UserStore } from "@webpack/common";
|
||||
import { PresenceStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
export interface Session {
|
||||
|
@ -44,10 +44,26 @@ const SessionsStore = findStoreLazy("SessionsStore") as {
|
|||
getSessions(): Record<string, Session>;
|
||||
};
|
||||
|
||||
function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) {
|
||||
return ({ color, tooltip, small }: { color: string; tooltip: string; small: boolean; }) => (
|
||||
const { useStatusFillColor } = mapMangledModuleLazy(".concat(.5625*", {
|
||||
useStatusFillColor: filters.byCode(".hex")
|
||||
});
|
||||
|
||||
interface IconFactoryOpts {
|
||||
viewBox?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
interface IconProps {
|
||||
color: string;
|
||||
tooltip: string;
|
||||
small?: boolean;
|
||||
}
|
||||
|
||||
function Icon(path: string, opts?: IconFactoryOpts) {
|
||||
return ({ color, tooltip, small }: IconProps) => (
|
||||
<Tooltip text={tooltip} >
|
||||
{(tooltipProps: any) => (
|
||||
{tooltipProps => (
|
||||
<svg
|
||||
{...tooltipProps}
|
||||
height={(opts?.height ?? 20) - (small ? 3 : 0)}
|
||||
|
@ -70,18 +86,22 @@ const Icons = {
|
|||
suncord: Icon("M7 4a6 6 0 00-6 6v4a6 6 0 006 6h10a6 6 0 006-6v-4a6 6 0 00-6-6H7zm0 11a1 1 0 01-1-1v-1H5a1 1 0 010-2h1v-1a1 1 0 012 0v1h1a1 1 0 010 2H8v1a1 1 0 01-1 1zm10-4a1 1 0 100-2 1 1 0 000 2zm1 3a1 1 0 11-2 0 1 1 0 012 0zm0-2a1 1 0 102 0 1 1 0 00-2 0zm-3 1a1 1 0 110-2 1 1 0 010 2z", { viewBox: "0 0 24 24", height: 24, width: 24 }),
|
||||
vencord: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", { viewBox: "0 0 50 50" }),
|
||||
};
|
||||
|
||||
type Platform = keyof typeof Icons;
|
||||
|
||||
const { useStatusFillColor } = mapMangledModuleLazy(".concat(.5625*", {
|
||||
useStatusFillColor: filters.byCode(".hex")
|
||||
});
|
||||
interface PlatformIconProps {
|
||||
platform: Platform;
|
||||
status: string;
|
||||
small?: boolean;
|
||||
isProfile?: boolean;
|
||||
}
|
||||
|
||||
const PlatformIcon = ({ platform, status, small }: { platform: Platform, status: string; small: boolean; }) => {
|
||||
const PlatformIcon = ({ platform, status, small }: PlatformIconProps) => {
|
||||
const tooltip = platform === "embedded"
|
||||
? "Console"
|
||||
: platform[0].toUpperCase() + platform.slice(1);
|
||||
let Icon = Icons[platform] ?? Icons.desktop;
|
||||
const { ConsoleIcon } = Settings.plugins.PlatformIndicators;
|
||||
const { ConsoleIcon } = settings.store;
|
||||
if (platform === "embedded" && ConsoleIcon === "vencord") {
|
||||
Icon = Icons.vencord;
|
||||
}
|
||||
|
@ -92,159 +112,166 @@ const PlatformIcon = ({ platform, status, small }: { platform: Platform, status:
|
|||
return <Icon color={useStatusFillColor(status)} tooltip={tooltip} small={small} />;
|
||||
};
|
||||
|
||||
function ensureOwnStatus(user: User) {
|
||||
if (user.id === UserStore.getCurrentUser().id) {
|
||||
const sessions = SessionsStore.getSessions();
|
||||
if (typeof sessions !== "object") return null;
|
||||
const sortedSessions = Object.values(sessions).sort(({ status: a }, { status: b }) => {
|
||||
if (a === b) return 0;
|
||||
if (a === "online") return 1;
|
||||
if (b === "online") return -1;
|
||||
if (a === "idle") return 1;
|
||||
if (b === "idle") return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
const ownStatus = Object.values(sortedSessions).reduce((acc, curr) => {
|
||||
if (curr.clientInfo.client !== "unknown")
|
||||
acc[curr.clientInfo.client] = curr.status;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const { clientStatuses } = PresenceStore.getState();
|
||||
clientStatuses[UserStore.getCurrentUser().id] = ownStatus;
|
||||
function useEnsureOwnStatus(user: User) {
|
||||
if (user.id !== UserStore.getCurrentUser()?.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sessions = useStateFromStores([SessionsStore], () => SessionsStore.getSessions());
|
||||
if (typeof sessions !== "object") return null;
|
||||
const sortedSessions = Object.values(sessions).sort(({ status: a }, { status: b }) => {
|
||||
if (a === b) return 0;
|
||||
if (a === "online") return 1;
|
||||
if (b === "online") return -1;
|
||||
if (a === "idle") return 1;
|
||||
if (b === "idle") return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
const ownStatus = Object.values(sortedSessions).reduce((acc, curr) => {
|
||||
if (curr.clientInfo.client !== "unknown")
|
||||
acc[curr.clientInfo.client] = curr.status;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const { clientStatuses } = PresenceStore.getState();
|
||||
clientStatuses[UserStore.getCurrentUser().id] = ownStatus;
|
||||
}
|
||||
|
||||
function getBadges({ userId }: BadgeUserArgs): ProfileBadge[] {
|
||||
const user = UserStore.getUser(userId);
|
||||
|
||||
if (!user || (user.bot && !Settings.plugins.PlatformIndicators.showBots)) return [];
|
||||
|
||||
ensureOwnStatus(user);
|
||||
|
||||
const status = PresenceStore.getState()?.clientStatuses?.[user.id] as Record<Platform, string>;
|
||||
if (!status) return [];
|
||||
|
||||
return Object.entries(status).map(([platform, status]) => ({
|
||||
component: () => (
|
||||
<span className="vc-platform-indicator">
|
||||
<PlatformIcon
|
||||
key={platform}
|
||||
platform={platform as Platform}
|
||||
status={status}
|
||||
small={false}
|
||||
/>
|
||||
</span>
|
||||
),
|
||||
key: `vc-platform-indicator-${platform}`
|
||||
}));
|
||||
interface PlatformIndicatorProps {
|
||||
user: User;
|
||||
isProfile?: boolean;
|
||||
isMessage?: boolean;
|
||||
isMemberList?: boolean;
|
||||
}
|
||||
|
||||
const PlatformIndicator = ({ user, small = false }: { user: User; small?: boolean; }) => {
|
||||
if (!user || (user.bot && !Settings.plugins.PlatformIndicators.showBots)) return null;
|
||||
const PlatformIndicator = ({ user, isProfile, isMessage, isMemberList }: PlatformIndicatorProps) => {
|
||||
if (user == null || user.bot) return null;
|
||||
useEnsureOwnStatus(user);
|
||||
|
||||
ensureOwnStatus(user);
|
||||
const status: Record<Platform, string> | undefined = useStateFromStores([PresenceStore], () => PresenceStore.getState()?.clientStatuses?.[user.id]);
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const status = PresenceStore.getState()?.clientStatuses?.[user.id] as Record<Platform, string>;
|
||||
if (!status) return null;
|
||||
|
||||
const icons = Object.entries(status).map(([platform, status]) => (
|
||||
const icons = Array.from(Object.entries(status), ([platform, status]) => (
|
||||
<PlatformIcon
|
||||
key={platform}
|
||||
platform={platform as Platform}
|
||||
status={status}
|
||||
small={small}
|
||||
small={isProfile || isMemberList}
|
||||
/>
|
||||
));
|
||||
|
||||
if (!icons.length) return null;
|
||||
if (!icons.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className="vc-platform-indicator"
|
||||
style={{ gap: "2px" }}
|
||||
<div
|
||||
className={classes("vc-platform-indicator", isProfile && "vc-platform-indicator-profile", isMessage && "vc-platform-indicator-message")}
|
||||
style={{ marginLeft: isMemberList ? "4px" : undefined }}
|
||||
>
|
||||
{icons}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const badge: ProfileBadge = {
|
||||
getBadges,
|
||||
position: BadgePosition.START,
|
||||
};
|
||||
function toggleMemberListDecorators(enabled: boolean) {
|
||||
if (enabled) {
|
||||
addMemberListDecorator("PlatformIndicators", props => <PlatformIndicator user={props.user} isMemberList />);
|
||||
} else {
|
||||
removeMemberListDecorator("PlatformIndicators");
|
||||
}
|
||||
}
|
||||
|
||||
const indicatorLocations = {
|
||||
function toggleNicknameIcons(enabled: boolean) {
|
||||
if (enabled) {
|
||||
addNicknameIcon("PlatformIndicators", props => <PlatformIndicator user={UserStore.getUser(props.userId)} isProfile />, 1);
|
||||
} else {
|
||||
removeNicknameIcon("PlatformIndicators");
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMessageDecorators(enabled: boolean) {
|
||||
if (enabled) {
|
||||
addMessageDecoration("PlatformIndicators", props => <PlatformIndicator user={props.message?.author} isMessage />);
|
||||
} else {
|
||||
removeMessageDecoration("PlatformIndicators");
|
||||
}
|
||||
}
|
||||
|
||||
migratePluginSetting("PlatformIndicators", "badges", "profiles");
|
||||
const settings = definePluginSettings({
|
||||
list: {
|
||||
description: "In the member list",
|
||||
onEnable: () => addMemberListDecorator("platform-indicator", props =>
|
||||
<ErrorBoundary noop>
|
||||
<PlatformIndicator user={props.user} small={true} />
|
||||
</ErrorBoundary>
|
||||
),
|
||||
onDisable: () => removeMemberListDecorator("platform-indicator")
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show indicators in the member list",
|
||||
default: true,
|
||||
onChange: toggleMemberListDecorators
|
||||
},
|
||||
badges: {
|
||||
description: "In user profiles, as badges",
|
||||
onEnable: () => addProfileBadge(badge),
|
||||
onDisable: () => removeProfileBadge(badge)
|
||||
profiles: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show indicators in user profiles",
|
||||
default: true,
|
||||
onChange: toggleNicknameIcons
|
||||
},
|
||||
messages: {
|
||||
description: "Inside messages",
|
||||
onEnable: () => addMessageDecoration("platform-indicator", props =>
|
||||
<ErrorBoundary noop>
|
||||
<PlatformIndicator user={props.message?.author} />
|
||||
</ErrorBoundary>
|
||||
),
|
||||
onDisable: () => removeMessageDecoration("platform-indicator")
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show indicators inside messages",
|
||||
default: true,
|
||||
onChange: toggleMessageDecorators
|
||||
},
|
||||
colorMobileIndicator: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Whether to make the mobile indicator match the color of the user status.",
|
||||
default: true,
|
||||
restartNeeded: true
|
||||
},
|
||||
ConsoleIcon: {
|
||||
type: OptionType.SELECT,
|
||||
description: "What console icon to use",
|
||||
restartNeeded: true,
|
||||
options: [
|
||||
{
|
||||
label: "Equicord",
|
||||
value: "equicord",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Suncord",
|
||||
value: "suncord",
|
||||
},
|
||||
{
|
||||
label: "Vencord",
|
||||
value: "vencord",
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
function addAllIndicators() {
|
||||
const settings = Settings.plugins.PlatformIndicators;
|
||||
const { displayMode } = settings;
|
||||
|
||||
// transfer settings from the old ones, which had a select menu instead of booleans
|
||||
if (displayMode) {
|
||||
if (displayMode !== "both") settings[displayMode] = true;
|
||||
else {
|
||||
settings.list = true;
|
||||
settings.badges = true;
|
||||
}
|
||||
settings.messages = true;
|
||||
delete settings.displayMode;
|
||||
}
|
||||
|
||||
Object.entries(indicatorLocations).forEach(([key, value]) => {
|
||||
if (settings[key]) value.onEnable();
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllIndicators() {
|
||||
Object.entries(indicatorLocations).forEach(([_, value]) => {
|
||||
value.onDisable();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "PlatformIndicators",
|
||||
description: "Adds platform indicators (Desktop, Mobile, Web...) to users",
|
||||
authors: [Devs.kemo, Devs.TheSun, Devs.Nuckyz, Devs.Ven],
|
||||
dependencies: ["MessageDecorationsAPI", "MemberListDecoratorsAPI"],
|
||||
dependencies: ["MemberListDecoratorsAPI", "NicknameIconsAPI", "MessageDecorationsAPI"],
|
||||
settings,
|
||||
|
||||
start() {
|
||||
addAllIndicators();
|
||||
if (settings.store.list) toggleMemberListDecorators(true);
|
||||
if (settings.store.profiles) toggleNicknameIcons(true);
|
||||
if (settings.store.messages) toggleMessageDecorators(true);
|
||||
},
|
||||
|
||||
stop() {
|
||||
deleteAllIndicators();
|
||||
if (settings.store.list) toggleMemberListDecorators(false);
|
||||
if (settings.store.profiles) toggleNicknameIcons;
|
||||
if (settings.store.messages) toggleMessageDecorators(false);
|
||||
},
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: ".Masks.STATUS_ONLINE_MOBILE",
|
||||
predicate: () => Settings.plugins.PlatformIndicators.colorMobileIndicator,
|
||||
predicate: () => settings.store.colorMobileIndicator,
|
||||
replacement: [
|
||||
{
|
||||
// Return the STATUS_ONLINE_MOBILE mask if the user is on mobile, no matter the status
|
||||
|
@ -260,7 +287,7 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: ".AVATAR_STATUS_MOBILE_16;",
|
||||
predicate: () => Settings.plugins.PlatformIndicators.colorMobileIndicator,
|
||||
predicate: () => settings.store.colorMobileIndicator,
|
||||
replacement: [
|
||||
{
|
||||
// Return the AVATAR_STATUS_MOBILE size mask if the user is on mobile, no matter the status
|
||||
|
@ -281,58 +308,12 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: "}isMobileOnline(",
|
||||
predicate: () => Settings.plugins.PlatformIndicators.colorMobileIndicator,
|
||||
predicate: () => settings.store.colorMobileIndicator,
|
||||
replacement: {
|
||||
// Make isMobileOnline return true no matter what is the user status
|
||||
match: /(?<=\i\[\i\.\i\.MOBILE\])===\i\.\i\.ONLINE/,
|
||||
replace: "!= null"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
options: {
|
||||
...Object.fromEntries(
|
||||
Object.entries(indicatorLocations).map(([key, value]) => {
|
||||
return [key, {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: `Show indicators ${value.description.toLowerCase()}`,
|
||||
// onChange doesn't give any way to know which setting was changed, so restart required
|
||||
restartNeeded: true,
|
||||
default: true
|
||||
}];
|
||||
})
|
||||
),
|
||||
colorMobileIndicator: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Whether to make the mobile indicator match the color of the user status.",
|
||||
default: true,
|
||||
restartNeeded: true
|
||||
},
|
||||
showBots: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Whether to show platform indicators on bots",
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
},
|
||||
ConsoleIcon: {
|
||||
type: OptionType.SELECT,
|
||||
description: "What console icon to use",
|
||||
restartNeeded: true,
|
||||
options: [
|
||||
{
|
||||
label: "Equicord",
|
||||
value: "equicord",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Suncord",
|
||||
value: "suncord",
|
||||
},
|
||||
{
|
||||
label: "Vencord",
|
||||
value: "vencord",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -2,6 +2,20 @@
|
|||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.vc-platform-indicator-profile {
|
||||
background: rgb(var(--bg-overlay-color) / var(--bg-overlay-opacity-6));
|
||||
border: 1px solid var(--border-faint);
|
||||
border-radius: var(--radius-xs);
|
||||
border-color: var(--profile-body-border-color);
|
||||
margin: 0 1px;
|
||||
padding: 0 1px;
|
||||
}
|
||||
|
||||
.vc-platform-indicator-message {
|
||||
position: relative;
|
||||
vertical-align: top;
|
||||
top: 2px;
|
||||
}
|
||||
|
|
|
@ -111,32 +111,32 @@ function VoiceChannelTooltip({ channel, isLocked }: VoiceChannelTooltipProps) {
|
|||
<Text variant="text-sm/bold">{guild.name}</Text>
|
||||
</div>
|
||||
)}
|
||||
<div className={cl("name2")} style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<div className={cl("name2")} style={{ display: "flex", alignItems: "center" }}>
|
||||
{channelIcon}
|
||||
<Text variant="text-sm/semibold">
|
||||
{channelName}
|
||||
</Text>
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginLeft: '10px' }}>
|
||||
<Text
|
||||
style={{
|
||||
color: 'gray',
|
||||
fontSize: '12px',
|
||||
boxSizing: 'border-box',
|
||||
padding: '0 6px 0 0',
|
||||
backgroundColor: 'var(--background-tertiary)',
|
||||
borderRadius: '0 8px 0 0',
|
||||
<div style={{ display: "flex", alignItems: "center", marginLeft: "10px" }}>
|
||||
<Text
|
||||
style={{
|
||||
color: "gray",
|
||||
fontSize: "12px",
|
||||
boxSizing: "border-box",
|
||||
padding: "0 6px 0 0",
|
||||
backgroundColor: "var(--background-tertiary)",
|
||||
borderRadius: "0 8px 0 0",
|
||||
}}
|
||||
>
|
||||
{users.length < 10 ? `0${users.length}` : `${users.length}`}
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
color: 'gray',
|
||||
fontSize: '12px',
|
||||
boxSizing: 'border-box',
|
||||
padding: '0 6px 0 0',
|
||||
backgroundColor: 'var(--background-mod-strong)',
|
||||
borderRadius: '0 8px 0 0',
|
||||
<Text
|
||||
style={{
|
||||
color: "gray",
|
||||
fontSize: "12px",
|
||||
boxSizing: "border-box",
|
||||
padding: "0 6px 0 0",
|
||||
backgroundColor: "var(--background-mod-strong)",
|
||||
borderRadius: "0 8px 0 0",
|
||||
}}
|
||||
>
|
||||
{channel.userLimit < 10 ? `0${channel.userLimit}` : `${channel.userLimit}`}
|
||||
|
@ -156,8 +156,10 @@ function VoiceChannelTooltip({ channel, isLocked }: VoiceChannelTooltipProps) {
|
|||
);
|
||||
}
|
||||
|
||||
export interface VoiceChannelIndicatorProps {
|
||||
interface VoiceChannelIndicatorProps {
|
||||
userId: string;
|
||||
isMessageIndicator?: boolean;
|
||||
isProfile?: boolean;
|
||||
isActionButton?: boolean;
|
||||
shouldHighlight?: boolean;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import "./style.css";
|
|||
|
||||
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
|
||||
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
|
||||
import { addNicknameIcon, removeNicknameIcon } from "@api/NicknameIcons";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
@ -51,38 +52,10 @@ export default definePlugin({
|
|||
name: "UserVoiceShow",
|
||||
description: "Shows an indicator when a user is in a Voice Channel",
|
||||
authors: [Devs.Nuckyz, Devs.LordElias, EquicordDevs.omaw],
|
||||
dependencies: ["MemberListDecoratorsAPI", "MessageDecorationsAPI"],
|
||||
dependencies: ["NicknameIconsAPI", "MemberListDecoratorsAPI", "MessageDecorationsAPI"],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
// User Popout, Full Size Profile, Direct Messages Side Profile
|
||||
{
|
||||
find: "#{intl::USER_PROFILE_LOAD_ERROR}",
|
||||
replacement: {
|
||||
match: /(\.fetchError.+?\?)null/,
|
||||
replace: (_, rest) => `${rest}$self.VoiceChannelIndicator({userId:arguments[0]?.userId})`
|
||||
},
|
||||
predicate: () => settings.store.showInUserProfileModal
|
||||
},
|
||||
// To use without the MemberList decorator API
|
||||
/* // Guild Members List
|
||||
{
|
||||
find: ".lostPermission)",
|
||||
replacement: {
|
||||
match: /\.lostPermission\).+?(?=avatar:)/,
|
||||
replace: "$&children:[$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})],"
|
||||
},
|
||||
predicate: () => settings.store.showVoiceChannelIndicator
|
||||
},
|
||||
// Direct Messages List
|
||||
{
|
||||
find: "PrivateChannel.renderAvatar",
|
||||
replacement: {
|
||||
match: /#{intl::CLOSE_DM}.+?}\)(?=])/,
|
||||
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
||||
},
|
||||
predicate: () => settings.store.showVoiceChannelIndicator
|
||||
}, */
|
||||
// Friends List
|
||||
{
|
||||
find: "null!=this.peopleListItemRef.current",
|
||||
|
@ -95,15 +68,19 @@ export default definePlugin({
|
|||
],
|
||||
|
||||
start() {
|
||||
if (settings.store.showInUserProfileModal) {
|
||||
addNicknameIcon("UserVoiceShow", ({ userId }) => <VoiceChannelIndicator userId={userId} isProfile />);
|
||||
}
|
||||
if (settings.store.showInMemberList) {
|
||||
addMemberListDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
|
||||
}
|
||||
if (settings.store.showInMessages) {
|
||||
addMessageDecoration("UserVoiceShow", ({ message }) => message?.author == null ? null : <VoiceChannelIndicator userId={message.author.id} />);
|
||||
addMessageDecoration("UserVoiceShow", ({ message }) => message?.author == null ? null : <VoiceChannelIndicator userId={message.author.id} isMessageIndicator />);
|
||||
}
|
||||
},
|
||||
|
||||
stop() {
|
||||
removeNicknameIcon("UserVoiceShow");
|
||||
removeMemberListDecorator("UserVoiceShow");
|
||||
removeMessageDecoration("UserVoiceShow");
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue