mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Compare commits
18 commits
4302b5c472
...
f53fb6946c
Author | SHA1 | Date | |
---|---|---|---|
|
f53fb6946c | ||
|
f12335a371 | ||
|
640d99dcda | ||
|
cecba0029f | ||
|
2e0977dd2b | ||
|
1b9ea1f413 | ||
|
cfb4972394 | ||
|
d0f048f81d | ||
|
a6058f8285 | ||
|
d17c0ea387 | ||
|
7ceaa5a6f0 | ||
|
2099d6ec94 | ||
|
2c33b5ac4d | ||
|
c27e01591e | ||
|
e5f743c922 | ||
|
8c0d54f13a | ||
|
ad64da0621 | ||
|
49c48393e0 |
17 changed files with 706 additions and 277 deletions
|
@ -1,5 +0,0 @@
|
||||||
# NoDefaultHangStatus
|
|
||||||
|
|
||||||
Disable the default hang status when joining voice channels
|
|
||||||
|
|
||||||
![Visualization](https://github.com/Vendicated/Vencord/assets/24937357/329a9742-236f-48f7-94ff-c3510eca505a)
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a Discord client mod
|
|
||||||
* Copyright (c) 2024 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: "NoDefaultHangStatus",
|
|
||||||
description: "Disable the default hang status when joining voice channels",
|
|
||||||
authors: [Devs.D3SOX],
|
|
||||||
|
|
||||||
patches: [
|
|
||||||
{
|
|
||||||
find: ".CHILLING)",
|
|
||||||
replacement: {
|
|
||||||
match: /{enableHangStatus:(\i),/,
|
|
||||||
replace: "{_enableHangStatus:$1=false,"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
110
src/plugins/showTimeoutDetails/TimeoutReasonStore.ts
Normal file
110
src/plugins/showTimeoutDetails/TimeoutReasonStore.ts
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { proxyLazy } from "@utils/lazy";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { Constants, Flux, FluxDispatcher, GuildMemberStore, PermissionsBits, PermissionStore, RestAPI, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
|
|
||||||
|
const AuditLogReasons: {
|
||||||
|
MEMBER_UPDATE: number;
|
||||||
|
AUTO_MODERATION_USER_COMMUNICATION_DISABLED: number;
|
||||||
|
[reason: string]: number;
|
||||||
|
} = findByPropsLazy("ALL", "AUTO_MODERATION_USER_COMMUNICATION_DISABLED", "MEMBER_UPDATE");
|
||||||
|
|
||||||
|
export type TimeoutEntry = {
|
||||||
|
reason: string | undefined;
|
||||||
|
moderator: string | undefined; // User ID of moderator, undefined if automod did the timeout
|
||||||
|
automod: boolean | undefined;
|
||||||
|
automodRuleName: string | undefined;
|
||||||
|
automodChannelId: string | undefined;
|
||||||
|
expires: string | undefined; // used to compare if timeout reason is different
|
||||||
|
loading: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NoTimeout: TimeoutEntry = {
|
||||||
|
reason: undefined,
|
||||||
|
moderator: undefined,
|
||||||
|
automod: undefined,
|
||||||
|
automodRuleName: undefined,
|
||||||
|
automodChannelId: undefined,
|
||||||
|
expires: undefined,
|
||||||
|
loading: false
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TimeoutLoading: TimeoutEntry = {
|
||||||
|
reason: undefined,
|
||||||
|
moderator: undefined,
|
||||||
|
automod: undefined,
|
||||||
|
automodRuleName: undefined,
|
||||||
|
automodChannelId: undefined,
|
||||||
|
expires: undefined,
|
||||||
|
loading: true
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TimeoutReasonStore = proxyLazy(() => {
|
||||||
|
class TimeoutReasonStore extends Flux.Store {
|
||||||
|
public reasonMap = new Map<string, TimeoutEntry>();
|
||||||
|
|
||||||
|
getReason(guildId: string, userId: string) {
|
||||||
|
const member = GuildMemberStore.getMember(guildId, userId);
|
||||||
|
|
||||||
|
if (!member?.communicationDisabledUntil) return NoTimeout;
|
||||||
|
if (new Date(member?.communicationDisabledUntil!) <= new Date()) return NoTimeout;
|
||||||
|
|
||||||
|
const reason = this.reasonMap.get(`${guildId}-${userId}`);
|
||||||
|
// Return if timeout reason entry is found and is up to date, or if it's still loading
|
||||||
|
if (reason && (reason.loading ? true : reason.expires === member?.communicationDisabledUntil)) return reason;
|
||||||
|
|
||||||
|
// The indicator being visible does not depend on any data here. This just returns that there's no extra information about the timeout.
|
||||||
|
if (!PermissionStore.canWithPartialContext(PermissionsBits.VIEW_AUDIT_LOG, { guildId })) return NoTimeout;
|
||||||
|
|
||||||
|
// Stop requesting data multiple times
|
||||||
|
this.reasonMap.set(`${guildId}-${userId}`, TimeoutLoading);
|
||||||
|
|
||||||
|
RestAPI.get({
|
||||||
|
url: Constants.Endpoints.GUILD_AUDIT_LOG(guildId),
|
||||||
|
query: {
|
||||||
|
// action_type is intentionally not specified here as we need multiple types of audit log actions.
|
||||||
|
target_id: userId,
|
||||||
|
limit: 100
|
||||||
|
}
|
||||||
|
}).then(logs => {
|
||||||
|
const entry = logs.body.audit_log_entries.find((entry: { action_type: number; changes: any[]; }) => {
|
||||||
|
if (entry.action_type === AuditLogReasons.AUTO_MODERATION_USER_COMMUNICATION_DISABLED) return true;
|
||||||
|
if (entry.action_type === AuditLogReasons.MEMBER_UPDATE && entry?.changes.some((change: { key: string; }) => change.key === "communication_disabled_until")) return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!entry) return this.reasonMap.set(`${guildId}-${userId}`, NoTimeout);
|
||||||
|
|
||||||
|
const isAutomod = entry.action_type === AuditLogReasons.AUTO_MODERATION_USER_COMMUNICATION_DISABLED;
|
||||||
|
|
||||||
|
this.reasonMap.set(`${guildId}-${userId}`, {
|
||||||
|
reason: entry.reason,
|
||||||
|
moderator: isAutomod ? undefined : entry.user_id,
|
||||||
|
automod: isAutomod,
|
||||||
|
automodRuleName: isAutomod ? entry?.options?.auto_moderation_rule_name : undefined,
|
||||||
|
automodChannelId: isAutomod ? entry?.options?.channel_id : undefined,
|
||||||
|
expires: member?.communicationDisabledUntil,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
|
||||||
|
// Re-render the timeout indicator components
|
||||||
|
this.emitChange();
|
||||||
|
});
|
||||||
|
|
||||||
|
return TimeoutLoading;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const store = new TimeoutReasonStore(FluxDispatcher, {});
|
||||||
|
|
||||||
|
return store;
|
||||||
|
});
|
||||||
|
|
||||||
|
export const useTimeoutReason = (guildId: string, userId: string) => useStateFromStores([TimeoutReasonStore], () => {
|
||||||
|
return TimeoutReasonStore.getReason(guildId, userId);
|
||||||
|
});
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { SafetyIcon } from "@components/Icons";
|
||||||
|
import { classes, Margins } from "@utils/index";
|
||||||
|
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
|
import { Button, Dialog, GuildMemberStore, GuildStore, i18n, Parser, PermissionsBits, PermissionStore, Text, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||||
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
import { CountDown } from "..";
|
||||||
|
import { useTimeoutReason } from "../TimeoutReasonStore";
|
||||||
|
import TimeoutDetailsRow from "./TimeoutDetailsRow";
|
||||||
|
|
||||||
|
const PopoutClasses = findByPropsLazy("container", "scroller", "list");
|
||||||
|
|
||||||
|
const TimeoutIcon = findComponentByCodeLazy("M12 23c.08 0 .14-.08.11-.16a2.88 2.88 0 0 1 .29-2.31l2.2-3.85");
|
||||||
|
const ChannelIcon = findComponentByCodeLazy("h4.97l-.8 4.84a1 1 0 0 0 1.97.32l.86-5.16H20a1");
|
||||||
|
const CustomAutoModRuleIcon = findComponentByCodeLazy("a1 1 0 0 1 1-1h8a1 1 0 0 1 0 2H3a1 1 0 0 1-1-1ZM3 19a1 1 0 1 0 0 2h8a1 1 0 0 0 0-2H3Z");
|
||||||
|
const MessageIcon = findComponentByCodeLazy('"M12 22a10 10 0 1 0-8.45-4.64c.13.19.11.44-.04.61l-2.06 2.37A1 1 0 0 0 2.2 22H12Z"');
|
||||||
|
|
||||||
|
const { setCommunicationDisabledUntil } = findByPropsLazy("setCommunicationDisabledUntil");
|
||||||
|
|
||||||
|
export default function TimeoutDetailsPopout({ closePopout, guildId, userId, message }: { closePopout(): void; guildId: string; userId: string; message: Message; }) {
|
||||||
|
const user = UserStore.getUser(userId);
|
||||||
|
const member = GuildMemberStore.getMember(guildId, userId);
|
||||||
|
const reason = useTimeoutReason(guildId, userId);
|
||||||
|
const hasModerationPermission = useStateFromStores([PermissionStore], () => PermissionStore.canManageUser(PermissionsBits.MODERATE_MEMBERS, userId, GuildStore.getGuild(guildId)));
|
||||||
|
const parse = (text: string) => Parser.parse(text, true, {
|
||||||
|
channelId: message.channel_id,
|
||||||
|
messageId: message.id
|
||||||
|
});
|
||||||
|
|
||||||
|
const [cancelling, setCancelling] = useState(false);
|
||||||
|
|
||||||
|
return <Dialog
|
||||||
|
className={classes("vc-std-popout", PopoutClasses.container)}
|
||||||
|
>
|
||||||
|
<Text tag="h2" variant="eyebrow" style={{ color: "var(--header-primary)", display: "inline" }}>
|
||||||
|
Timeout details for {user.username}
|
||||||
|
</Text>
|
||||||
|
<div className={Margins.bottom8} />
|
||||||
|
|
||||||
|
<TimeoutDetailsRow
|
||||||
|
description="Remaining time in timeout"
|
||||||
|
icon={TimeoutIcon}
|
||||||
|
>
|
||||||
|
<CountDown
|
||||||
|
deadline={new Date(member.communicationDisabledUntil!)}
|
||||||
|
showUnits
|
||||||
|
stopAtOneSec
|
||||||
|
/>
|
||||||
|
</TimeoutDetailsRow>
|
||||||
|
|
||||||
|
<TimeoutDetailsRow
|
||||||
|
description="Moderator"
|
||||||
|
icon={SafetyIcon}
|
||||||
|
condition={!!(reason.moderator || reason.automod)}
|
||||||
|
>
|
||||||
|
{reason.automod ? i18n.Messages.GUILD_SETTINGS_AUTOMOD_TITLE : parse(`<@${reason.moderator}>`)}
|
||||||
|
</TimeoutDetailsRow>
|
||||||
|
|
||||||
|
<TimeoutDetailsRow
|
||||||
|
description="Channel where offending message was sent"
|
||||||
|
icon={ChannelIcon}
|
||||||
|
condition={!!reason.automodChannelId}
|
||||||
|
>
|
||||||
|
{parse(`<#${reason.automodChannelId}>`)}
|
||||||
|
</TimeoutDetailsRow>
|
||||||
|
|
||||||
|
<TimeoutDetailsRow
|
||||||
|
description="AutoMod Rule"
|
||||||
|
icon={CustomAutoModRuleIcon}
|
||||||
|
>
|
||||||
|
{reason.automodRuleName}
|
||||||
|
</TimeoutDetailsRow>
|
||||||
|
|
||||||
|
<TimeoutDetailsRow
|
||||||
|
description="Reason"
|
||||||
|
icon={MessageIcon}
|
||||||
|
>
|
||||||
|
{reason.reason}
|
||||||
|
</TimeoutDetailsRow>
|
||||||
|
|
||||||
|
{hasModerationPermission && <div className="vc-std-popout-button-wrapper"><Button
|
||||||
|
className="vc-std-popout-button"
|
||||||
|
size={Button.Sizes.SMALL}
|
||||||
|
color={Button.Colors.RED}
|
||||||
|
onClick={async () => {
|
||||||
|
setCancelling(true);
|
||||||
|
await setCommunicationDisabledUntil({
|
||||||
|
guildId,
|
||||||
|
userId,
|
||||||
|
communicationDisabledUntilTimestamp: null,
|
||||||
|
duratiion: null,
|
||||||
|
reason: null,
|
||||||
|
location: null
|
||||||
|
});
|
||||||
|
closePopout();
|
||||||
|
}}
|
||||||
|
submitting={cancelling}
|
||||||
|
>
|
||||||
|
{i18n.Messages.REMOVE_TIME_OUT}
|
||||||
|
</Button></div>}
|
||||||
|
</Dialog>;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { Tooltip } from "@webpack/common";
|
||||||
|
import { JSXElementConstructor, ReactNode } from "react";
|
||||||
|
|
||||||
|
const rowClasses = findByPropsLazy("row", "rowIcon", "rowGuildName");
|
||||||
|
|
||||||
|
export default function TimeoutDetailsRow(props: {
|
||||||
|
description: ReactNode;
|
||||||
|
icon: JSXElementConstructor<any>;
|
||||||
|
children: ReactNode;
|
||||||
|
condition?: boolean | string;
|
||||||
|
}) {
|
||||||
|
if (props.condition === undefined ? !props.children : !props.condition) return null;
|
||||||
|
return <div className={rowClasses.row}>
|
||||||
|
<Tooltip text={props.description}>
|
||||||
|
{p => <props.icon {...p} className={rowClasses.rowIcon} height="24" width="24" />}
|
||||||
|
</Tooltip>
|
||||||
|
{props.children}
|
||||||
|
</div>;
|
||||||
|
}
|
92
src/plugins/showTimeoutDetails/components/TooltipWrapper.tsx
Normal file
92
src/plugins/showTimeoutDetails/components/TooltipWrapper.tsx
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { classes, Margins } from "@utils/index";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { ChannelStore, GuildMemberStore, i18n, Popout, Text, Tooltip } from "@webpack/common";
|
||||||
|
import { Message } from "discord-types/general";
|
||||||
|
import { FunctionComponent, ReactNode } from "react";
|
||||||
|
|
||||||
|
import { CountDown, DisplayStyle, settings } from "..";
|
||||||
|
import { useTimeoutReason } from "../TimeoutReasonStore";
|
||||||
|
import TimeoutDetailsPopout from "./TimeoutDetailsPopout";
|
||||||
|
|
||||||
|
const clickableClasses = findByPropsLazy("clickable", "avatar", "username");
|
||||||
|
|
||||||
|
export default function TooltipWrapper({ message, children, text }: { message: Message; children: FunctionComponent<any>; text: ReactNode; }) {
|
||||||
|
const guildId = ChannelStore.getChannel(message.channel_id)?.guild_id;
|
||||||
|
const timeoutReason = useTimeoutReason(guildId, message.author.id);
|
||||||
|
|
||||||
|
if (settings.store.displayStyle === DisplayStyle.Tooltip) return <Tooltip
|
||||||
|
tooltipClassName="vc-std-tooltip"
|
||||||
|
text={renderTimeout(message, false)}
|
||||||
|
children={(props: any) => (
|
||||||
|
<Popout
|
||||||
|
position="top"
|
||||||
|
align="left"
|
||||||
|
renderPopout={p => <TimeoutDetailsPopout {...p} guildId={guildId} userId={message.author.id} message={message} />}
|
||||||
|
>
|
||||||
|
{popoutProps => <span
|
||||||
|
{...popoutProps}
|
||||||
|
className={classes("vc-std-icon", clickableClasses.clickable, timeoutReason.automod && "vc-std-automod")}
|
||||||
|
onClick={e => { e.stopPropagation(); popoutProps.onClick(e); }} // stop double click to reply/edit
|
||||||
|
>
|
||||||
|
{children(props)}
|
||||||
|
</span>}
|
||||||
|
</Popout>
|
||||||
|
)}
|
||||||
|
/>;
|
||||||
|
return (
|
||||||
|
<Popout
|
||||||
|
position="top"
|
||||||
|
align="left"
|
||||||
|
renderPopout={p => <TimeoutDetailsPopout {...p} guildId={guildId} userId={message.author.id} message={message} />}
|
||||||
|
>
|
||||||
|
{popoutProps => <div
|
||||||
|
{...popoutProps}
|
||||||
|
className={classes("vc-std-wrapper", clickableClasses.clickable, timeoutReason.automod && "vc-std-automod")}
|
||||||
|
onClick={e => { e.stopPropagation(); popoutProps.onClick(e); }} // stop double click to reply/edit
|
||||||
|
>
|
||||||
|
<Tooltip text={text} children={children} />
|
||||||
|
<span className={Margins.right8} />
|
||||||
|
<Text variant="text-md/normal" className="vc-std-wrapper-text">
|
||||||
|
{renderTimeout(message, true)} timeout remaining
|
||||||
|
</Text>
|
||||||
|
</div>}
|
||||||
|
</Popout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTimeout(message: Message, inline: boolean) {
|
||||||
|
const guildId = ChannelStore.getChannel(message.channel_id)?.guild_id;
|
||||||
|
if (!guildId) return null;
|
||||||
|
|
||||||
|
const member = GuildMemberStore.getMember(guildId, message.author.id);
|
||||||
|
if (!member?.communicationDisabledUntil) return null;
|
||||||
|
|
||||||
|
const countdown = () => <>
|
||||||
|
<wbr />
|
||||||
|
<span style={{ whiteSpace: "nowrap" }}>
|
||||||
|
<CountDown
|
||||||
|
deadline={new Date(member.communicationDisabledUntil!)}
|
||||||
|
showUnits
|
||||||
|
stopAtOneSec
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<wbr />
|
||||||
|
</>;
|
||||||
|
|
||||||
|
return inline
|
||||||
|
? countdown()
|
||||||
|
: <>
|
||||||
|
{i18n.Messages.GUILD_ENABLE_COMMUNICATION_TIME_REMAINING.format({
|
||||||
|
username: message.author.username,
|
||||||
|
countdown
|
||||||
|
})}
|
||||||
|
<br />
|
||||||
|
Click for more details.
|
||||||
|
</>;
|
||||||
|
}
|
61
src/plugins/showTimeoutDetails/index.tsx
Normal file
61
src/plugins/showTimeoutDetails/index.tsx
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import "./styles.css";
|
||||||
|
|
||||||
|
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { findComponentLazy } from "@webpack";
|
||||||
|
|
||||||
|
import TooltipWrapper from "./components/TooltipWrapper";
|
||||||
|
import { TimeoutReasonStore } from "./TimeoutReasonStore";
|
||||||
|
|
||||||
|
export const CountDown = findComponentLazy(m => m.prototype?.render?.toString().includes(".MAX_AGE_NEVER"));
|
||||||
|
|
||||||
|
export const enum DisplayStyle {
|
||||||
|
Tooltip = "tooltip",
|
||||||
|
Inline = "ssalggnikool"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const settings = definePluginSettings({
|
||||||
|
displayStyle: {
|
||||||
|
description: "How to display the timeout duration and reason",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
options: [
|
||||||
|
{ label: "In the Tooltip", value: DisplayStyle.Tooltip },
|
||||||
|
{ label: "Next to the timeout icon", value: DisplayStyle.Inline, default: true },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
migratePluginSettings("ShowTimeoutDetails", "ShowTimeoutDuration");
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "ShowTimeoutDetails",
|
||||||
|
description: "Shows how much longer a user's timeout will last and why they are timed out, either in the timeout icon tooltip or next to it",
|
||||||
|
authors: [Devs.Ven, Devs.Sqaaakoi],
|
||||||
|
tags: ["ShowTimeoutDuration", "ShowTimeoutReason"],
|
||||||
|
|
||||||
|
settings,
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".GUILD_COMMUNICATION_DISABLED_ICON_TOOLTIP_BODY",
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
match: /(\i)\.Tooltip,{(text:.{0,30}\.Messages\.GUILD_COMMUNICATION_DISABLED_ICON_TOOLTIP_BODY)/,
|
||||||
|
replace: "$self.TooltipWrapper,{message:arguments[0].message,$2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
TimeoutReasonStore,
|
||||||
|
|
||||||
|
TooltipWrapper: ErrorBoundary.wrap(TooltipWrapper, { noop: true })
|
||||||
|
});
|
35
src/plugins/showTimeoutDetails/styles.css
Normal file
35
src/plugins/showTimeoutDetails/styles.css
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
.vc-std-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-wrapper [class*="communicationDisabled"] {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-wrapper-text {
|
||||||
|
color: var(--status-danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-automod :is(svg, .vc-std-wrapper-text) {
|
||||||
|
color: var(--status-warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-tooltip {
|
||||||
|
max-width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-popout {
|
||||||
|
width: unset;
|
||||||
|
min-width: 180px;
|
||||||
|
max-width: 360px;
|
||||||
|
color: var(--text-normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-popout-button-wrapper {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-std-popout-button {
|
||||||
|
padding: 2px 10px;
|
||||||
|
}
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a Discord client mod
|
|
||||||
* Copyright (c) 2024 Vendicated and contributors
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import "./styles.css";
|
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
|
||||||
import { findComponentLazy } from "@webpack";
|
|
||||||
import { ChannelStore, GuildMemberStore, i18n, Text, Tooltip } from "@webpack/common";
|
|
||||||
import { Message } from "discord-types/general";
|
|
||||||
import { FunctionComponent, ReactNode } from "react";
|
|
||||||
|
|
||||||
const CountDown = findComponentLazy(m => m.prototype?.render?.toString().includes(".MAX_AGE_NEVER"));
|
|
||||||
|
|
||||||
const enum DisplayStyle {
|
|
||||||
Tooltip = "tooltip",
|
|
||||||
Inline = "ssalggnikool"
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
|
||||||
displayStyle: {
|
|
||||||
description: "How to display the timeout duration",
|
|
||||||
type: OptionType.SELECT,
|
|
||||||
options: [
|
|
||||||
{ label: "In the Tooltip", value: DisplayStyle.Tooltip },
|
|
||||||
{ label: "Next to the timeout icon", value: DisplayStyle.Inline, default: true },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function renderTimeout(message: Message, inline: boolean) {
|
|
||||||
const guildId = ChannelStore.getChannel(message.channel_id)?.guild_id;
|
|
||||||
if (!guildId) return null;
|
|
||||||
|
|
||||||
const member = GuildMemberStore.getMember(guildId, message.author.id);
|
|
||||||
if (!member?.communicationDisabledUntil) return null;
|
|
||||||
|
|
||||||
const countdown = () => (
|
|
||||||
<CountDown
|
|
||||||
deadline={new Date(member.communicationDisabledUntil!)}
|
|
||||||
showUnits
|
|
||||||
stopAtOneSec
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return inline
|
|
||||||
? countdown()
|
|
||||||
: i18n.Messages.GUILD_ENABLE_COMMUNICATION_TIME_REMAINING.format({
|
|
||||||
username: message.author.username,
|
|
||||||
countdown
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "ShowTimeoutDuration",
|
|
||||||
description: "Shows how much longer a user's timeout will last, either in the timeout icon tooltip or next to it",
|
|
||||||
authors: [Devs.Ven, Devs.Sqaaakoi],
|
|
||||||
|
|
||||||
settings,
|
|
||||||
|
|
||||||
patches: [
|
|
||||||
{
|
|
||||||
find: ".GUILD_COMMUNICATION_DISABLED_ICON_TOOLTIP_BODY",
|
|
||||||
replacement: [
|
|
||||||
{
|
|
||||||
match: /(\i)\.Tooltip,{(text:.{0,30}\.Messages\.GUILD_COMMUNICATION_DISABLED_ICON_TOOLTIP_BODY)/,
|
|
||||||
replace: "$self.TooltipWrapper,{message:arguments[0].message,$2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
TooltipWrapper: ErrorBoundary.wrap(({ message, children, text }: { message: Message; children: FunctionComponent<any>; text: ReactNode; }) => {
|
|
||||||
if (settings.store.displayStyle === DisplayStyle.Tooltip) return <Tooltip
|
|
||||||
children={children}
|
|
||||||
text={renderTimeout(message, false)}
|
|
||||||
/>;
|
|
||||||
return (
|
|
||||||
<div className="vc-std-wrapper">
|
|
||||||
<Tooltip text={text} children={children} />
|
|
||||||
<Text variant="text-md/normal" color="status-danger">
|
|
||||||
{renderTimeout(message, true)} timeout remaining
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}, { noop: true })
|
|
||||||
});
|
|
|
@ -1,8 +0,0 @@
|
||||||
.vc-std-wrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-std-wrapper [class*="communicationDisabled"] {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
7
src/plugins/userVoiceShow/README.md
Normal file
7
src/plugins/userVoiceShow/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# User Voice Show
|
||||||
|
|
||||||
|
Shows an indicator when a user is in a Voice Channel
|
||||||
|
|
||||||
|
![a preview of the indicator in the user profile](https://github.com/user-attachments/assets/48f825e4-fad5-40d7-bb4f-41d5e595aae0)
|
||||||
|
|
||||||
|
![a preview of the indicator in the member list](https://github.com/user-attachments/assets/51be081d-7bbb-45c5-8533-d565228e50c1)
|
170
src/plugins/userVoiceShow/components.tsx
Normal file
170
src/plugins/userVoiceShow/components.tsx
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { classes } from "@utils/misc";
|
||||||
|
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||||
|
import { ChannelStore, GuildStore, IconUtils, NavigationRouter, PermissionsBits, PermissionStore, showToast, Text, Toasts, Tooltip, useCallback, useMemo, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-uvs-");
|
||||||
|
|
||||||
|
const { selectVoiceChannel } = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
||||||
|
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
||||||
|
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
|
|
||||||
|
interface IconProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SpeakerIcon(props: IconProps) {
|
||||||
|
props.size ??= 16;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
role={props.onClick != null ? "button" : undefined}
|
||||||
|
className={classes(cl("speaker"), props.onClick != null ? cl("clickable") : undefined)}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width={props.size}
|
||||||
|
height={props.size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path d="M12 3a1 1 0 0 0-1-1h-.06a1 1 0 0 0-.74.32L5.92 7H3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2.92l4.28 4.68a1 1 0 0 0 .74.32H11a1 1 0 0 0 1-1V3ZM15.1 20.75c-.58.14-1.1-.33-1.1-.92v-.03c0-.5.37-.92.85-1.05a7 7 0 0 0 0-13.5A1.11 1.11 0 0 1 14 4.2v-.03c0-.6.52-1.06 1.1-.92a9 9 0 0 1 0 17.5Z" />
|
||||||
|
<path d="M15.16 16.51c-.57.28-1.16-.2-1.16-.83v-.14c0-.43.28-.8.63-1.02a3 3 0 0 0 0-5.04c-.35-.23-.63-.6-.63-1.02v-.14c0-.63.59-1.1 1.16-.83a5 5 0 0 1 0 9.02Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LockedSpeakerIcon(props: IconProps) {
|
||||||
|
props.size ??= 16;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
role={props.onClick != null ? "button" : undefined}
|
||||||
|
className={classes(cl("speaker"), props.onClick != null ? cl("clickable") : undefined)}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width={props.size}
|
||||||
|
height={props.size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path fillRule="evenodd" clipRule="evenodd" d="M16 4h.5v-.5a2.5 2.5 0 0 1 5 0V4h.5a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Zm4-.5V4h-2v-.5a1 1 0 1 1 2 0Z" />
|
||||||
|
<path d="M11 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1h-.06a1 1 0 0 1-.74-.32L5.92 17H3a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.92l4.28-4.68a1 1 0 0 1 .74-.32H11ZM20.5 12c-.28 0-.5.22-.52.5a7 7 0 0 1-5.13 6.25c-.48.13-.85.55-.85 1.05v.03c0 .6.52 1.06 1.1.92a9 9 0 0 0 6.89-8.25.48.48 0 0 0-.49-.5h-1ZM16.5 12c-.28 0-.5.23-.54.5a3 3 0 0 1-1.33 2.02c-.35.23-.63.6-.63 1.02v.14c0 .63.59 1.1 1.16.83a5 5 0 0 0 2.82-4.01c.02-.28-.2-.5-.48-.5h-1Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VoiceChannelTooltipProps {
|
||||||
|
channel: Channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
||||||
|
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
|
||||||
|
const users = useMemo(
|
||||||
|
() => Object.values<any>(voiceStates).map(voiceState => UserStore.getUser(voiceState.userId)).filter(user => user != null),
|
||||||
|
[voiceStates]
|
||||||
|
);
|
||||||
|
|
||||||
|
const guild = useMemo(
|
||||||
|
() => channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId()),
|
||||||
|
[channel]
|
||||||
|
);
|
||||||
|
|
||||||
|
const guildIcon = useMemo(() => {
|
||||||
|
return guild?.icon == null ? undefined : IconUtils.getGuildIconURL({
|
||||||
|
id: guild.id,
|
||||||
|
icon: guild.icon,
|
||||||
|
size: 30
|
||||||
|
});
|
||||||
|
}, [guild]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{guild != null && (
|
||||||
|
<div className={cl("guild-name")}>
|
||||||
|
{guildIcon != null && <img className={cl("guild-icon")} src={guildIcon} alt="" />}
|
||||||
|
<Text variant="text-sm/bold">{guild.name}</Text>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Text variant="text-sm/semibold">{channel.name}</Text>
|
||||||
|
<div className={cl("vc-members")}>
|
||||||
|
<SpeakerIcon size={18} />
|
||||||
|
<UserSummaryItem
|
||||||
|
users={users}
|
||||||
|
renderIcon={false}
|
||||||
|
max={7}
|
||||||
|
size={18}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VoiceChannelIndicatorProps {
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clickTimers = {} as Record<string, any>;
|
||||||
|
|
||||||
|
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChannelIndicatorProps) => {
|
||||||
|
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
|
||||||
|
const channel = useMemo(() => channelId == null ? undefined : ChannelStore.getChannel(channelId), [channelId]);
|
||||||
|
|
||||||
|
const onClick = useCallback((e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
if (channel == null || channelId == null) return;
|
||||||
|
|
||||||
|
if (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) {
|
||||||
|
showToast("You cannot view the user's Voice Channel", Toasts.Type.FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearTimeout(clickTimers[channelId]);
|
||||||
|
delete clickTimers[channelId];
|
||||||
|
|
||||||
|
if (e.detail > 1) {
|
||||||
|
if (!PermissionStore.can(PermissionsBits.CONNECT, channel)) {
|
||||||
|
showToast("You cannot join the user's Voice Channel", Toasts.Type.FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectVoiceChannel(channelId);
|
||||||
|
} else {
|
||||||
|
clickTimers[channelId] = setTimeout(() => {
|
||||||
|
NavigationRouter.transitionTo(`/channels/${channel.getGuildId() ?? "@me"}/${channelId}`);
|
||||||
|
delete clickTimers[channelId];
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
}, [channelId]);
|
||||||
|
|
||||||
|
const isLocked = useMemo(() => {
|
||||||
|
return !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel);
|
||||||
|
}, [channelId]);
|
||||||
|
|
||||||
|
if (channel == null) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
text={<VoiceChannelTooltip channel={channel} />}
|
||||||
|
tooltipClassName={cl("tooltip-container")}
|
||||||
|
>
|
||||||
|
{props =>
|
||||||
|
isLocked ?
|
||||||
|
<LockedSpeakerIcon {...props} onClick={onClick} />
|
||||||
|
: <SpeakerIcon {...props} onClick={onClick} />
|
||||||
|
}
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}, { noop: true });
|
|
@ -1,27 +0,0 @@
|
||||||
.vc-uvs-button>div {
|
|
||||||
white-space: normal !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-button {
|
|
||||||
width: 100%;
|
|
||||||
margin: auto;
|
|
||||||
height: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-header {
|
|
||||||
color: var(--header-primary);
|
|
||||||
margin-bottom: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-modal-margin {
|
|
||||||
margin: 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-modal-margin div {
|
|
||||||
margin-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-popout-margin-self>[class^="section"] {
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import "./VoiceChannelSection.css";
|
|
||||||
|
|
||||||
import { findByPropsLazy } from "@webpack";
|
|
||||||
import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
|
|
||||||
import { Channel } from "discord-types/general";
|
|
||||||
|
|
||||||
const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
|
||||||
|
|
||||||
const CONNECT = 1n << 20n;
|
|
||||||
|
|
||||||
interface VoiceChannelFieldProps {
|
|
||||||
channel: Channel;
|
|
||||||
label: string;
|
|
||||||
showHeader: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => (
|
|
||||||
// @TODO The div is supposed to be a UserPopoutSection
|
|
||||||
<div>
|
|
||||||
{showHeader && <Forms.FormTitle className="vc-uvs-header">In a voice channel</Forms.FormTitle>}
|
|
||||||
<Button
|
|
||||||
className="vc-uvs-button"
|
|
||||||
color={Button.Colors.TRANSPARENT}
|
|
||||||
size={Button.Sizes.SMALL}
|
|
||||||
|
|
||||||
onClick={() => {
|
|
||||||
if (PermissionStore.can(CONNECT, channel))
|
|
||||||
ChannelActions.selectVoiceChannel(channel.id);
|
|
||||||
else
|
|
||||||
Toasts.show({
|
|
||||||
message: "Insufficient permissions to enter the channel.",
|
|
||||||
id: "user-voice-show-insufficient-permissions",
|
|
||||||
type: Toasts.Type.FAILURE,
|
|
||||||
options: {
|
|
||||||
position: Toasts.Position.BOTTOM,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
|
@ -16,85 +16,85 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./style.css";
|
||||||
|
|
||||||
|
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
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 { findStoreLazy } from "@webpack";
|
|
||||||
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
|
|
||||||
import { User } from "discord-types/general";
|
|
||||||
|
|
||||||
import { VoiceChannelSection } from "./components/VoiceChannelSection";
|
import { VoiceChannelIndicator } from "./components";
|
||||||
|
|
||||||
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showInUserProfileModal: {
|
showInUserProfileModal: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Show a user's voice channel in their profile modal",
|
description: "Show a user's Voice Channel indicator in their profile next to the name",
|
||||||
default: true,
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
},
|
},
|
||||||
showVoiceChannelSectionHeader: {
|
showInVoiceMemberList: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: 'Whether to show "IN A VOICE CHANNEL" above the join button',
|
description: "Show a user's Voice Channel indicator in the member and DMs list",
|
||||||
default: true,
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
interface UserProps {
|
|
||||||
user: User;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VoiceChannelField = ErrorBoundary.wrap(({ user }: UserProps) => {
|
|
||||||
const { channelId } = VoiceStateStore.getVoiceStateForUser(user.id) ?? {};
|
|
||||||
if (!channelId) return null;
|
|
||||||
|
|
||||||
const channel = ChannelStore.getChannel(channelId);
|
|
||||||
if (!channel) return null;
|
|
||||||
|
|
||||||
const guild = GuildStore.getGuild(channel.guild_id);
|
|
||||||
|
|
||||||
if (!guild) return null; // When in DM call
|
|
||||||
|
|
||||||
const result = `${guild.name} | ${channel.name}`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<VoiceChannelSection
|
|
||||||
channel={channel}
|
|
||||||
label={result}
|
|
||||||
showHeader={settings.store.showVoiceChannelSectionHeader}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "UserVoiceShow",
|
name: "UserVoiceShow",
|
||||||
description: "Shows whether a User is currently in a voice channel somewhere in their profile",
|
description: "Shows an indicator when a user is in a Voice Channel",
|
||||||
authors: [Devs.LordElias],
|
authors: [Devs.LordElias, Devs.Nuckyz],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patchModal({ user }: UserProps) {
|
|
||||||
if (!settings.store.showInUserProfileModal)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="vc-uvs-modal-margin">
|
|
||||||
<VoiceChannelField user={user} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
patchProfilePopout: ({ user }: UserProps) => {
|
|
||||||
const isSelfUser = user.id === UserStore.getCurrentUser().id;
|
|
||||||
return (
|
|
||||||
<div className={isSelfUser ? "vc-uvs-popout-margin-self" : ""}>
|
|
||||||
<VoiceChannelField user={user} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
// @TODO Maybe patch UserVoiceShow in simplified profile popout
|
// User Popout, Full Size Profile, Direct Messages Side Profile
|
||||||
// @TODO Patch new profile modal
|
{
|
||||||
|
find: ".Messages.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: /\.Messages\.CLOSE_DM.+?}\)(?=])/,
|
||||||
|
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.showVoiceChannelIndicator
|
||||||
|
}, */
|
||||||
|
// Friends List
|
||||||
|
{
|
||||||
|
find: ".avatar,animate:",
|
||||||
|
replacement: {
|
||||||
|
match: /\.subtext,children:.+?}\)\]}\)(?=])/,
|
||||||
|
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.showInVoiceMemberList
|
||||||
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if (settings.store.showInVoiceMemberList) {
|
||||||
|
addDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
removeDecorator("UserVoiceShow");
|
||||||
|
},
|
||||||
|
|
||||||
|
VoiceChannelIndicator
|
||||||
});
|
});
|
||||||
|
|
37
src/plugins/userVoiceShow/style.css
Normal file
37
src/plugins/userVoiceShow/style.css
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
.vc-uvs-speaker {
|
||||||
|
color: var(--interactive-normal);
|
||||||
|
padding: 0 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-clickable:hover {
|
||||||
|
color: var(--interactive-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-tooltip-container {
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-guild-name {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-guild-icon {
|
||||||
|
border-radius: 100%;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-vc-members {
|
||||||
|
display: flex;
|
||||||
|
margin: 8px 0;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
Loading…
Reference in a new issue