|
|
@ -24,6 +24,22 @@ import { GuildStore, i18n, RestAPI } from "@webpack/common";
|
|
|
|
|
|
|
|
|
|
|
|
const { InvitesDisabledExperiment } = findByPropsLazy("InvitesDisabledExperiment");
|
|
|
|
const { InvitesDisabledExperiment } = findByPropsLazy("InvitesDisabledExperiment");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showDisableInvites(guildId: string) {
|
|
|
|
|
|
|
|
// Once the experiment is removed, this should keep working
|
|
|
|
|
|
|
|
const { enableInvitesDisabled } = InvitesDisabledExperiment?.getCurrentConfig?.({ guildId }) ?? { enableInvitesDisabled: true };
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
return enableInvitesDisabled && !GuildStore.getGuild(guildId).hasFeature("INVITES_DISABLED");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function disableInvites(guildId: string) {
|
|
|
|
|
|
|
|
const guild = GuildStore.getGuild(guildId);
|
|
|
|
|
|
|
|
const features = [...guild.features, "INVITES_DISABLED"];
|
|
|
|
|
|
|
|
RestAPI.patch({
|
|
|
|
|
|
|
|
url: `/guilds/${guild.id}`,
|
|
|
|
|
|
|
|
body: { features },
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default definePlugin({
|
|
|
|
export default definePlugin({
|
|
|
|
name: "PauseInvitesForever",
|
|
|
|
name: "PauseInvitesForever",
|
|
|
|
tags: ["DisableInvitesForever"],
|
|
|
|
tags: ["DisableInvitesForever"],
|
|
|
@ -33,44 +49,29 @@ export default definePlugin({
|
|
|
|
patches: [
|
|
|
|
patches: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
find: "Messages.GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION",
|
|
|
|
find: "Messages.GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION",
|
|
|
|
replacement: [{
|
|
|
|
group: true,
|
|
|
|
match: /children:\i\.\i\.\i\.GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION/,
|
|
|
|
replacement: [
|
|
|
|
replace: "children: $self.renderInvitesLabel(arguments[0].guildId, setChecked)",
|
|
|
|
{
|
|
|
|
},
|
|
|
|
match: /children:\i\.\i\.\i\.GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION/,
|
|
|
|
{
|
|
|
|
replace: "children: $self.renderInvitesLabel({guildId:arguments[0].guildId,setChecked})",
|
|
|
|
match: /(\i\.hasDMsDisabled\)\(\i\),\[\i,(\i)\]=\i\.useState\(\i\))/,
|
|
|
|
},
|
|
|
|
replace: "$1,setChecked=$2"
|
|
|
|
{
|
|
|
|
}]
|
|
|
|
match: /(\i\.hasDMsDisabled\)\(\i\),\[\i,(\i)\]=\i\.useState\(\i\))/,
|
|
|
|
|
|
|
|
replace: "$1,setChecked=$2"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
showDisableInvites(guildId: string) {
|
|
|
|
renderInvitesLabel: ErrorBoundary.wrap(({ guildId, setChecked }) => {
|
|
|
|
// Once the experiment is removed, this should keep working
|
|
|
|
|
|
|
|
const { enableInvitesDisabled } = InvitesDisabledExperiment?.getCurrentConfig?.({ guildId }) ?? { enableInvitesDisabled: true };
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
return enableInvitesDisabled && !GuildStore.getGuild(guildId).hasFeature("INVITES_DISABLED");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
disableInvites(guildId: string) {
|
|
|
|
|
|
|
|
const guild = GuildStore.getGuild(guildId);
|
|
|
|
|
|
|
|
const features = [...guild.features, "INVITES_DISABLED"];
|
|
|
|
|
|
|
|
RestAPI.patch({
|
|
|
|
|
|
|
|
url: `/guilds/${guild.id}`,
|
|
|
|
|
|
|
|
body: { features },
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderInvitesLabel(guildId: string, setChecked: Function) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<ErrorBoundary noop>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{i18n.Messages.GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION}
|
|
|
|
{i18n.Messages.GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION}
|
|
|
|
{showDisableInvites(guildId) && <a role="button" onClick={() => {
|
|
|
|
{this.showDisableInvites(guildId) && <a role="button" onClick={() => {
|
|
|
|
setChecked(true);
|
|
|
|
setChecked(true);
|
|
|
|
disableInvites(guildId);
|
|
|
|
this.disableInvites(guildId);
|
|
|
|
}}> Pause Indefinitely.</a>}
|
|
|
|
}}> Pause Indefinitely.</a>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</ErrorBoundary>
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|