Plugin

PauseInvitesForever

Brings back the option to pause invites indefinitely that stupit Discord removed.

Servers
index.tsx
Download

Source

src/plugins/pauseInvitesForever/index.tsx
1import ErrorBoundary from "@components/ErrorBoundary";
2import { Devs } from "@utils/constants";
3import { getIntlMessage, hasGuildFeature } from "@utils/discord";
4import definePlugin from "@utils/types";
5import { Constants, GuildStore, PermissionStore, RestAPI } from "@webpack/common";
6
7function 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).canManageRoles
14 );
15}
16
17function 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
26export 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