diff --git a/src/plugins/customBanReasons/index.tsx b/src/plugins/customBanReasons/index.tsx new file mode 100644 index 000000000..ccda69f8b --- /dev/null +++ b/src/plugins/customBanReasons/index.tsx @@ -0,0 +1,100 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Button, Forms, TextInput, useEffect, useState } from "@webpack/common"; + +function ReasonsComponent() { + const [reasons, setReasons] = useState(settings.store.reasons as string[]); + + useEffect(() => { + settings.store.reasons = reasons; + }, [reasons]); + + return ( + + {reasons.map((reason, index) => ( +
+ { + reasons[index] = value; + setReasons([...reasons]); + }} + placeholder="Reason" + /> + +
+ ))} + +
+ ); +} + +const settings = definePluginSettings({ + reasons: { + description: "Your custom reasons", + type: OptionType.COMPONENT, + default: [ + "Suspicious or spam account", + "Compromised or spam account", + "Breaking server rules", + ], + component: ReasonsComponent, + }, +}); + +export default definePlugin({ + name: "CustomBanReasons", + description: "Create custom reasons to use in the Discord ban modal.", + authors: [Devs.Inbestigator], + patches: [ + { + find: 'username:"@".concat(_.default.getName', + replacement: { + match: /U=\[([\s\S]*?)\]/, + replace: "U=$self.getReasons()", + }, + }, + ], + getReasons: (): { name: string; value: string; }[] => { + return settings.store.reasons.map((reason: string) => { + return { name: reason, value: reason }; + }); + }, + settings, +});