Plugin

PermissionFreeWill

Disables the client-side restrictions for channel permission management.

Servers Roles
index.ts
Download

Source

src/plugins/permissionFreeWill/index.ts
1import { definePluginSettings } from "@api/Settings";
2import { Devs } from "@utils/constants";
3import { canonicalizeMatch } from "@utils/patches";
4import definePlugin, { OptionType } from "@utils/types";
5
6const settings = definePluginSettings({
7 lockout: {
8 type: OptionType.BOOLEAN,
9 default: true,
10 description: 'Bypass the permission lockout prevention ("Pretty sure you don\'t want to do this")',
11 restartNeeded: true
12 },
13 onboarding: {
14 type: OptionType.BOOLEAN,
15 default: true,
16 description: 'Bypass the onboarding requirements ("Making this change will make your server incompatible [...]")',
17 restartNeeded: true
18 }
19});
20
21export default definePlugin({
22 name: "PermissionFreeWill",
23 description: "Disables the client-side restrictions for channel permission management.",
24 tags: ["Servers", "Roles"],
25 authors: [Devs.lewisakura],
26
27 patches: [
28 // Permission lockout, just set the check to true
29 {
30 find: "#{intl::STAGE_CHANNEL_CANNOT_OVERWRITE_PERMISSION}",
31 replacement: [
32 {
33 match: /case"DENY":.{0,50}if\((?=\i\.\i\.can)/,
34 replace: "$&true||"
35 }
36 ],
37 predicate: () => settings.store.lockout
38 },
39 // Onboarding, same thing but we need to prevent the check
40 {
41 find: "#{intl::ONBOARDING_CHANNEL_THRESHOLD_WARNING}",
42 replacement: [
43 {
44 // replace export getters with functions that always resolve to true
45 match: /{(?:\i:\(\)=>\i,?){2}}/,
46 replace: m => m.replaceAll(canonicalizeMatch(/\(\)=>\i/g), "()=>()=>Promise.resolve(true)")
47 }
48 ],
49 predicate: () => settings.store.onboarding
50 }
51 ],
52 settings
53});
54