Plugin
PauseInvitesForever
Brings back the option to pause invites indefinitely that stupit Discord removed.
1
import ErrorBoundary from "@components/ErrorBoundary";2
import { Devs } from "@utils/constants";3
import { getIntlMessage, hasGuildFeature } from "@utils/discord";4
import definePlugin from "@utils/types";5
import { Constants, GuildStore, PermissionStore, RestAPI } from "@webpack/common";6
7
function showDisableInvites(guildId: string) {8
const guild = GuildStore.getGuild(guildId);9
if (!guild) return false;10
11
return (12
!hasGuildFeature(guild, "INVITES_DISABLED") &&13
PermissionStore.getGuildPermissionProps(guild).canManageRoles14
);15
}16
17
function disableInvites(guildId: string) {18
const guild = GuildStore.getGuild(guildId);19
const features = [...guild.features, "INVITES_DISABLED"];20
RestAPI.patch({21
url: Constants.Endpoints.GUILD(guildId),22
body: { features },23
});24
}25
26
export default definePlugin({27
name: "PauseInvitesForever",28
searchTerms: ["DisableInvitesForever"],29
description: "Brings back the option to pause invites indefinitely that stupit Discord removed.",30
tags: ["Servers"],31
authors: [Devs.Dolfies, Devs.amia],32
33
patches: [34
{35
find: "#{intl::GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION}",36
group: true,37
replacement: [38
{39
match: /children:\i\.\i\.string\(\i\.\i#{intl::GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION}\)/,40
replace: "children: $self.renderInvitesLabel({guildId:arguments[0].guildId,setChecked})",41
},42
{43
match: /\.INVITES_DISABLED\)(?=.+?#{intl::INVITES_PERMANENTLY_DISABLED_TIP}.+?checked:(\i)).+?\[\1,(\i)\]=\i.useState\(\i\)/,44
replace: "$&,setChecked=$2"45
}46
]47
}48
],49
50
renderInvitesLabel: ErrorBoundary.wrap(({ guildId, setChecked }) => {51
return (52
<div>53
{getIntlMessage("GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION")}54
{showDisableInvites(guildId) && <a role="button" onClick={() => {55
setChecked(true);56
disableInvites(guildId);57
}}> Pause Indefinitely.</a>}58
</div>59
);60
}, { noop: true })61
});62