Plugin
PermissionFreeWill
Disables the client-side restrictions for channel permission management.
1
import { definePluginSettings } from "@api/Settings";2
import { Devs } from "@utils/constants";3
import { canonicalizeMatch } from "@utils/patches";4
import definePlugin, { OptionType } from "@utils/types";5
6
const settings = definePluginSettings({7
lockout: {8
type: OptionType.BOOLEAN,9
default: true,10
description: 039;Bypass the permission lockout prevention ("Pretty sure you don\039;t want to do this")039;,11
restartNeeded: true12
},13
onboarding: {14
type: OptionType.BOOLEAN,15
default: true,16
description: 039;Bypass the onboarding requirements ("Making this change will make your server incompatible [...]")039;,17
restartNeeded: true18
}19
});20
21
export 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 true29
{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.lockout38
},39
// Onboarding, same thing but we need to prevent the check40
{41
find: "#{intl::ONBOARDING_CHANNEL_THRESHOLD_WARNING}",42
replacement: [43
{44
// replace export getters with functions that always resolve to true45
match: /{(?:\i:\(\)=>\i,?){2}}/,46
replace: m => m.replaceAll(canonicalizeMatch(/\(\)=>\i/g), "()=>()=>Promise.resolve(true)")47
}48
],49
predicate: () => settings.store.onboarding50
}51
],52
settings53
});54