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