Skip to content

Commit

Permalink
experiments: remove obsolete isStaff patch; rename ServerProfile -> S…
Browse files Browse the repository at this point in the history
…erverInfo
  • Loading branch information
Vendicated committed Jun 5, 2024
1 parent 6e6ee4d commit a2730e5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 60 deletions.
54 changes: 10 additions & 44 deletions src/plugins/experiments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { ErrorCard } from "@components/ErrorCard";
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins";
import definePlugin, { OptionType } from "@utils/types";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Forms, React, UserStore } from "@webpack/common";
import { User } from "discord-types/general";
import { Forms, React } from "@webpack/common";

const KbdStyles = findByPropsLazy("key", "removeBuildOverride");

const settings = definePluginSettings({
enableIsStaff: {
description: "Enable isStaff",
type: OptionType.BOOLEAN,
default: false,
restartNeeded: true
}
});

export default definePlugin({
name: "Experiments",
description: "Enable Access to Experiments in Discord!",
description: "Enable Access to Experiments & other dev-only features in Discord!",
authors: [
Devs.Megu,
Devs.Ven,
Devs.Nickyux,
Devs.BanTheNons,
Devs.Nuckyz
],
settings,

patches: [
{
Expand All @@ -65,20 +52,6 @@ export default definePlugin({
replace: "$1=!0;"
}
},
{
find: '"isStaff",',
predicate: () => settings.store.enableIsStaff,
replacement: [
{
match: /(?<=>)(\i)\.hasFlag\((\i\.\i)\.STAFF\)(?=})/,
replace: (_, user, flags) => `$self.isStaff(${user},${flags})`
},
{
match: /hasFreePremium\(\){return this.isStaff\(\)\s*?\|\|/,
replace: "hasFreePremium(){return ",
}
]
},
{
find: 'H1,title:"Experiments"',
replacement: {
Expand All @@ -88,15 +61,6 @@ export default definePlugin({
}
],

isStaff(user: User, flags: any) {
try {
return UserStore.getCurrentUser()?.id === user.id || user.hasFlag(flags.STAFF);
} catch (err) {
new Logger("Experiments").error(err);
return user.hasFlag(flags.STAFF);
}
},

settingsAboutComponent: () => {
const isMacOS = navigator.platform.includes("Mac");
const modKey = isMacOS ? "cmd" : "ctrl";
Expand All @@ -105,14 +69,10 @@ export default definePlugin({
<React.Fragment>
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
<Forms.FormText variant="text-md/normal">
You can enable client DevTools{" "}
You can open Discord's DevTools via {" "}
<kbd className={KbdStyles.key}>{modKey}</kbd> +{" "}
<kbd className={KbdStyles.key}>{altKey}</kbd> +{" "}
<kbd className={KbdStyles.key}>O</kbd>{" "}
after enabling <code>isStaff</code> below
</Forms.FormText>
<Forms.FormText>
and then toggling <code>Enable DevTools</code> in the <code>Developer Options</code> tab in settings.
</Forms.FormText>
</React.Fragment>
);
Expand All @@ -128,6 +88,12 @@ export default definePlugin({

<Forms.FormText className={Margins.top8}>
Only use experiments if you know what you're doing. Vencord is not responsible for any damage caused by enabling experiments.

If you don't know what an experiment does, ignore it. Do not ask us what experiments do either, we probably don't know.
</Forms.FormText>

<Forms.FormText className={Margins.top8}>
No, you cannot use server-side features like checking the "Send to Client" box.
</Forms.FormText>
</ErrorCard>
), { noop: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const FriendRow = findExportedComponentLazy("FriendRow");

const cl = classNameFactory("vc-gp-");

export function openGuildProfileModal(guild: Guild) {
export function openGuildInfoModal(guild: Guild) {
openModal(props =>
<ModalRoot {...props} size={ModalSize.MEDIUM}>
<GuildProfileModal guild={guild} />
<GuildInfoModal guild={guild} />
</ModalRoot>
);
}
Expand Down Expand Up @@ -53,7 +53,7 @@ function renderTimestamp(timestamp: number) {
);
}

function GuildProfileModal({ guild }: GuildProps) {
function GuildInfoModal({ guild }: GuildProps) {
const [friendCount, setFriendCount] = useState<number>();
const [blockedCount, setBlockedCount] = useState<number>();

Expand Down
7 changes: 7 additions & 0 deletions src/plugins/serverInfo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ServerInfo

Allows you to view info about servers and see friends and blocked users

![](https://github.com/Vendicated/Vencord/assets/45497981/a49783b5-e8fc-41d8-968f-58600e9f6580)
![](https://github.com/Vendicated/Vencord/assets/45497981/5efc158a-e671-4196-a15a-77edf79a2630)
![Available as "Server Profile" option in the server context menu](https://github.com/Vendicated/Vencord/assets/45497981/f43be943-6dc4-4232-9709-fbeb382d8e54)
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@
*/

import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { migratePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { Menu } from "@webpack/common";
import { Guild } from "discord-types/general";

import { openGuildProfileModal } from "./GuildProfileModal";
import { openGuildInfoModal } from "./GuildInfoModal";

const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild; }) => {
const group = findGroupChildrenByChildId("privacy", children);

group?.push(
<Menu.MenuItem
id="vc-server-profile"
id="vc-server-info"
label="Server Info"
action={() => openGuildProfileModal(guild)}
action={() => openGuildInfoModal(guild)}
/>
);
};

migratePluginSettings("ServerInfo", "ServerProfile"); // what was I thinking with this name lmao
export default definePlugin({
name: "ServerProfile",
description: "Allows you to view info about a server by right clicking it in the server list",
name: "ServerInfo",
description: "Allows you to view info about a server",
authors: [Devs.Ven, Devs.Nuckyz],
tags: ["guild", "info"],
tags: ["guild", "info", "ServerProfile"],
contextMenus: {
"guild-context": Patch,
"guild-header-popout": Patch
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions src/plugins/serverProfile/README.md

This file was deleted.

0 comments on commit a2730e5

Please sign in to comment.