mirror of
https://github.com/Equicord/Equicord.git
synced 2025-03-14 14:10:26 -04:00
Why is every other match of this not conflicting
This commit is contained in:
parent
fad16cefaf
commit
09331c12c9
5 changed files with 12 additions and 225 deletions
|
@ -21,17 +21,14 @@ import { getListeners } from "./utils";
|
||||||
|
|
||||||
const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider");
|
const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider");
|
||||||
|
|
||||||
function ToolBarHeader() {
|
function OpenLogsButton() {
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary noop={true}>
|
<HeaderBarIcon
|
||||||
<HeaderBarIcon
|
className="chatBarLogIcon"
|
||||||
tooltip="Open SoundBoard Log"
|
onClick={() => openSoundBoardLog()}
|
||||||
position="bottom"
|
tooltip={"Open SoundBoard Log"}
|
||||||
className="vc-soundboard-logger"
|
icon={<LogIcon className="chatBarLogIcon" />}
|
||||||
icon={<LogIcon className="chatBarLogIcon" />}
|
/>
|
||||||
onClick={openSoundBoardLog}
|
|
||||||
/>
|
|
||||||
</ErrorBoundary>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +42,7 @@ export default definePlugin({
|
||||||
find: "toolbar:function",
|
find: "toolbar:function",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(function \i\(\i\){)(.{1,200}toolbar.{1,100}mobileToolbar)/,
|
match: /(function \i\(\i\){)(.{1,200}toolbar.{1,100}mobileToolbar)/,
|
||||||
replace: "$1$self.toolbarAction(arguments[0]);$2"
|
replace: "$1$self.addIconToToolBar(arguments[0]);$2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -63,19 +60,19 @@ export default definePlugin({
|
||||||
disableStyle(styles);
|
disableStyle(styles);
|
||||||
if (settings.store.IconLocation === "chat") removeChatBarButton("vc-soundlog-button");
|
if (settings.store.IconLocation === "chat") removeChatBarButton("vc-soundlog-button");
|
||||||
},
|
},
|
||||||
toolbarAction(e) {
|
addIconToToolBar(e: { toolbar: React.ReactNode[] | React.ReactNode; }) {
|
||||||
if (Array.isArray(e.toolbar))
|
if (Array.isArray(e.toolbar))
|
||||||
return e.toolbar.push(
|
return e.toolbar.push(
|
||||||
<ErrorBoundary noop={true}>
|
<ErrorBoundary noop={true}>
|
||||||
<ToolBarHeader />
|
<OpenLogsButton />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
|
|
||||||
e.toolbar = [
|
e.toolbar = [
|
||||||
<ErrorBoundary noop={true}>
|
<ErrorBoundary noop={true}>
|
||||||
<ToolBarHeader />
|
<OpenLogsButton />
|
||||||
</ErrorBoundary>,
|
</ErrorBoundary>,
|
||||||
e.toolbar,
|
e.toolbar,
|
||||||
];
|
];
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -188,14 +188,6 @@ export default definePlugin({
|
||||||
description: "Show connected accounts in user popouts",
|
description: "Show connected accounts in user popouts",
|
||||||
authors: [Devs.TheKodeToad],
|
authors: [Devs.TheKodeToad],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
|
||||||
find: ".PROFILE_PANEL,",
|
|
||||||
replacement: {
|
|
||||||
// createElement(Divider, {}), createElement(NoteComponent)
|
|
||||||
match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/,
|
|
||||||
replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: '"BiteSizeProfileBody"',
|
find: '"BiteSizeProfileBody"',
|
||||||
replacement: {
|
replacement: {
|
||||||
|
|
|
@ -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 { findByCodeLazy, findByPropsLazy } from "@webpack";
|
|
||||||
import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
|
|
||||||
import { Channel } from "discord-types/general";
|
|
||||||
|
|
||||||
const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
|
||||||
const UserPopoutSection = findByCodeLazy(".lastSection", "children:");
|
|
||||||
|
|
||||||
const CONNECT = 1n << 20n;
|
|
||||||
|
|
||||||
interface VoiceChannelFieldProps {
|
|
||||||
channel: Channel;
|
|
||||||
label: string;
|
|
||||||
showHeader: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => (
|
|
||||||
<UserPopoutSection>
|
|
||||||
{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>
|
|
||||||
</UserPopoutSection>
|
|
||||||
);
|
|
|
@ -1,114 +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 { definePluginSettings } from "@api/Settings";
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
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";
|
|
||||||
|
|
||||||
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
|
||||||
showInUserProfileModal: {
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
description: "Show a user's voice channel in their profile modal",
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
showVoiceChannelSectionHeader: {
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
description: 'Whether to show "IN A VOICE CHANNEL" above the join button',
|
|
||||||
default: 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({
|
|
||||||
name: "UserVoiceShow",
|
|
||||||
description: "Shows whether a User is currently in a voice channel somewhere in their profile",
|
|
||||||
authors: [Devs.LordElias],
|
|
||||||
settings,
|
|
||||||
|
|
||||||
patchModal({ user }: UserProps) {
|
|
||||||
if (!settings.store.showInUserProfileModal)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="vc-uvs-modal-margin">
|
|
||||||
<VoiceChannelField user={user} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
patchPopout: ({ user }: UserProps) => {
|
|
||||||
const isSelfUser = user.id === UserStore.getCurrentUser().id;
|
|
||||||
return (
|
|
||||||
<div className={isSelfUser ? "vc-uvs-popout-margin-self" : ""}>
|
|
||||||
<VoiceChannelField user={user} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
patches: [
|
|
||||||
// above message box
|
|
||||||
{
|
|
||||||
find: ".popularApplicationCommandIds,",
|
|
||||||
replacement: {
|
|
||||||
match: /(?<=,)(?=!\i&&!\i&&.{0,50}setNote:)/,
|
|
||||||
replace: "$self.patchPopout(arguments[0]),",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// below username
|
|
||||||
{
|
|
||||||
find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Lazy Loaded
|
|
||||||
replacement: {
|
|
||||||
match: /\.body.+?displayProfile:\i}\),/,
|
|
||||||
replace: "$&$self.patchModal(arguments[0]),",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
});
|
|
Loading…
Add table
Reference in a new issue