Merge branch 'dev' into plugin/audioPlaybackSpeed

This commit is contained in:
vee 2024-06-06 01:03:24 +02:00 committed by GitHub
commit 3fb8e433e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 61 deletions

View file

@ -12,7 +12,8 @@ body:
DO NOT USE THIS FORM, unless DO NOT USE THIS FORM, unless
- you are a vencord contributor - you are a vencord contributor
- you were given explicit permission to use this form by a moderator in our support server - you were given explicit permission to use this form by a moderator in our support server
- you are filing a security related report
DO NOT USE THIS FORM FOR SECURITY RELATED ISSUES. [CREATE A SECURITY ADVISORY INSTEAD.](https://github.com/Vendicated/Vencord/security/advisories/new)
- type: textarea - type: textarea
id: content id: content

View file

@ -16,31 +16,19 @@
* 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 { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { ErrorCard } from "@components/ErrorCard"; import { ErrorCard } from "@components/ErrorCard";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { Forms, React, UserStore } from "@webpack/common"; import { Forms, React } from "@webpack/common";
import { User } from "discord-types/general";
const KbdStyles = findByPropsLazy("key", "removeBuildOverride"); const KbdStyles = findByPropsLazy("key", "removeBuildOverride");
const settings = definePluginSettings({
enableIsStaff: {
description: "Enable isStaff",
type: OptionType.BOOLEAN,
default: false,
restartNeeded: true
}
});
export default definePlugin({ export default definePlugin({
name: "Experiments", name: "Experiments",
description: "Enable Access to Experiments in Discord!", description: "Enable Access to Experiments & other dev-only features in Discord!",
authors: [ authors: [
Devs.Megu, Devs.Megu,
Devs.Ven, Devs.Ven,
@ -48,7 +36,6 @@ export default definePlugin({
Devs.BanTheNons, Devs.BanTheNons,
Devs.Nuckyz Devs.Nuckyz
], ],
settings,
patches: [ patches: [
{ {
@ -65,20 +52,6 @@ export default definePlugin({
replace: "$1=!0;" 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"', find: 'H1,title:"Experiments"',
replacement: { 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: () => { settingsAboutComponent: () => {
const isMacOS = navigator.platform.includes("Mac"); const isMacOS = navigator.platform.includes("Mac");
const modKey = isMacOS ? "cmd" : "ctrl"; const modKey = isMacOS ? "cmd" : "ctrl";
@ -105,14 +69,10 @@ export default definePlugin({
<React.Fragment> <React.Fragment>
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle> <Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
<Forms.FormText variant="text-md/normal"> <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}>{modKey}</kbd> +{" "}
<kbd className={KbdStyles.key}>{altKey}</kbd> +{" "} <kbd className={KbdStyles.key}>{altKey}</kbd> +{" "}
<kbd className={KbdStyles.key}>O</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> </Forms.FormText>
</React.Fragment> </React.Fragment>
); );
@ -128,6 +88,12 @@ export default definePlugin({
<Forms.FormText className={Margins.top8}> <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. 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> </Forms.FormText>
</ErrorCard> </ErrorCard>
), { noop: true }) ), { noop: true })

View file

@ -20,10 +20,10 @@ const FriendRow = findExportedComponentLazy("FriendRow");
const cl = classNameFactory("vc-gp-"); const cl = classNameFactory("vc-gp-");
export function openGuildProfileModal(guild: Guild) { export function openGuildInfoModal(guild: Guild) {
openModal(props => openModal(props =>
<ModalRoot {...props} size={ModalSize.MEDIUM}> <ModalRoot {...props} size={ModalSize.MEDIUM}>
<GuildProfileModal guild={guild} /> <GuildInfoModal guild={guild} />
</ModalRoot> </ModalRoot>
); );
} }
@ -53,7 +53,7 @@ function renderTimestamp(timestamp: number) {
); );
} }
function GuildProfileModal({ guild }: GuildProps) { function GuildInfoModal({ guild }: GuildProps) {
const [friendCount, setFriendCount] = useState<number>(); const [friendCount, setFriendCount] = useState<number>();
const [blockedCount, setBlockedCount] = useState<number>(); const [blockedCount, setBlockedCount] = useState<number>();

View 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)

View file

@ -5,30 +5,32 @@
*/ */
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { migratePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { Menu } from "@webpack/common"; import { Menu } from "@webpack/common";
import { Guild } from "discord-types/general"; import { Guild } from "discord-types/general";
import { openGuildProfileModal } from "./GuildProfileModal"; import { openGuildInfoModal } from "./GuildInfoModal";
const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild; }) => { const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild; }) => {
const group = findGroupChildrenByChildId("privacy", children); const group = findGroupChildrenByChildId("privacy", children);
group?.push( group?.push(
<Menu.MenuItem <Menu.MenuItem
id="vc-server-profile" id="vc-server-info"
label="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({ export default definePlugin({
name: "ServerProfile", name: "ServerInfo",
description: "Allows you to view info about a server by right clicking it in the server list", description: "Allows you to view info about a server",
authors: [Devs.Ven, Devs.Nuckyz], authors: [Devs.Ven, Devs.Nuckyz],
tags: ["guild", "info"], tags: ["guild", "info", "ServerProfile"],
contextMenus: { contextMenus: {
"guild-context": Patch, "guild-context": Patch,
"guild-header-popout": Patch "guild-header-popout": Patch

View file

@ -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)