experiments: remove obsolete isStaff patch; rename ServerProfile -> ServerInfo
This commit is contained in:
parent
23584393a9
commit
9ab7b8b9c9
|
@ -16,31 +16,19 @@
|
|||
* 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,
|
||||
|
@ -48,7 +36,6 @@ export default definePlugin({
|
|||
Devs.BanTheNons,
|
||||
Devs.Nuckyz
|
||||
],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
|
@ -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: {
|
||||
|
@ -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";
|
||||
|
@ -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>
|
||||
);
|
||||
|
@ -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 })
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
@ -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>();
|
||||
|
7
src/plugins/serverInfo/README.md
Normal file
7
src/plugins/serverInfo/README.md
Normal file
|
@ -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)
|
|
@ -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
|
|
@ -1,7 +0,0 @@
|
|||
# ServerProfile
|
||||
|
||||
Allows you to view info about servers and see friends and blocked users
|
||||
|
||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/a49783b5-e8fc-41d8-968f-58600e9f6580)
|
||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/5efc158a-e671-4196-a15a-77edf79a2630)
|
||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/f43be943-6dc4-4232-9709-fbeb382d8e54)
|
Loading…
Reference in a new issue