diff --git a/src/equicordplugins/betterBanReasons/index.tsx b/src/equicordplugins/betterBanReasons/index.tsx index 86d0b6dfe..179ab8004 100644 --- a/src/equicordplugins/betterBanReasons/index.tsx +++ b/src/equicordplugins/betterBanReasons/index.tsx @@ -9,48 +9,82 @@ import "./styles.css"; import { definePluginSettings } from "@api/Settings"; import { Heading } from "@components/Heading"; import { DeleteIcon, PlusIcon } from "@components/Icons"; -import { Devs } from "@utils/constants"; +import { Devs, EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, TextInput } from "@webpack/common"; +import { Button, Select, TextInput, useState } from "@webpack/common"; const cl = classNameFactory("vc-bbr-"); +interface BanReason { + text: string; + deleteSeconds?: number; +} + +const DELETE_DURATION_OPTIONS = [ + { label: "Discord default", value: null }, + { label: "Don't delete any", value: 0 }, + { label: "Previous hour", value: 3600 }, + { label: "Previous 6 hours", value: 21600 }, + { label: "Previous 12 hours", value: 43200 }, + { label: "Previous 24 hours", value: 86400 }, + { label: "Previous 3 days", value: 259200 }, + { label: "Previous 7 days", value: 604800 }, +]; + +function normalizeReason(r: BanReason | string): BanReason { + return typeof r === "string" ? { text: r } : r; +} + +function getStoredReasons(): BanReason[] { + return (settings.store.reasons as (BanReason | string)[]).map(normalizeReason); +} + function ReasonsComponent() { - const { reasons } = settings.store; + const [reasons, setReasons] = useState(getStoredReasons); + + const update = (next: BanReason[]) => { + setReasons(next); + settings.store.reasons = next; + }; return (
Reasons {reasons.map((r, i) => ( -
+
{ - reasons[i] = v; - settings.store.reasons = reasons; - }} + value={r.text} + onChange={v => update(reasons.map((x, j) => j === i ? { ...x, text: v } : x))} placeholder="Reason" /> +
+ Message Auto-delete duration +