From 562e8065c2c631c03e4886071b18399228713146 Mon Sep 17 00:00:00 2001 From: nin0dev Date: Sun, 1 Sep 2024 08:52:25 -0400 Subject: [PATCH] h --- Modals.tsx | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.tsx | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 Modals.tsx create mode 100644 index.tsx create mode 100644 style.css diff --git a/Modals.tsx b/Modals.tsx new file mode 100644 index 0000000..d3a5277 --- /dev/null +++ b/Modals.tsx @@ -0,0 +1,59 @@ +import ErrorBoundary from "@components/ErrorBoundary"; +import { openModal, ModalRoot, ModalSize, ModalHeader, ModalCloseButton, ModalContent, closeModal, closeAllModals } from "@utils/modal"; +import { Button, Forms, Parser, TextInput } from "@webpack/common"; +import { cl } from "plugins/memberCount"; +import { SelectedChannelStore, useState } from "@webpack/common"; +import "./style.css"; +import { sendMessage } from "@utils/discord"; + +export function showPrefefinedDurationModal(duration: string, id: string) { + let reason = ""; + openModal(props => + <> + + + + Mute user + + + { reason = v; }} placeholder="Reason" className="vc-punishcommands-reason" /> +
+ +
+
+
+
+ + ); +} +export function showCustomDurationModal(id: string) { + let duration = ""; + let reason = ""; + let pendingSend = false; + openModal(props => + <> + + + + Mute user + + + { duration = v; }} placeholder="Duration (as written in the command)" className="vc-punishcommands-duration-c" /> + { reason = v; }} placeholder="Reason" className="vc-punishcommands-reason-c" /> +
+ +
+
+
+
+ + ); +} diff --git a/index.tsx b/index.tsx new file mode 100644 index 0000000..4cf1ede --- /dev/null +++ b/index.tsx @@ -0,0 +1,63 @@ +import { NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { ImageIcon, SafetyIcon } from "@components/Icons"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { showCustomDurationModal, showPrefefinedDurationModal } from "./Modals"; +import { GuildMemberStore, i18n, IconUtils, Menu, SelectedGuildStore } from "@webpack/common"; +import { UserContextProps } from "plugins/biggerStreamPreview"; + +/**** BEGIN CONFIG ****/ +const GUILD_ID = "1274790619146879108"; // SERVER ID +/**** END CONFIG ****/ + +const UserContext: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => { + if (!user) return; + children.splice(-3, 0, + ( + <> + {SelectedGuildStore.getGuildId() === GUILD_ID && + <> + + { + showPrefefinedDurationModal("1h", user.id); + }} + icon={SafetyIcon} + /> + { + showPrefefinedDurationModal("2h", user.id); + }} + icon={SafetyIcon} + /> + { + showCustomDurationModal(user.id); + }} + icon={SafetyIcon} + /> + + + } + + ) + ); +}; + +export default definePlugin({ + name: "PunishmentCommands", + description: "Allows you to send a command in chat to punish someone, right from the context menu", + authors: [Devs.nin0dev], + contextMenus: { + "user-context": UserContext + } +}); diff --git a/style.css b/style.css new file mode 100644 index 0000000..8ac0b3e --- /dev/null +++ b/style.css @@ -0,0 +1,55 @@ +/* stylelint-disable selector-id-pattern */ +/* stylelint-disable declaration-block-no-redundant-longhand-properties */ +#user-context-vc-staff--mute-1h { + color: var(--status-danger); +} + +#user-context-vc-staff--mute-1h[class*="focused"] { + background-color: var(--menu-item-danger-hover-bg); + color: white; +} + +#user-context-vc-staff--mute-2h { + color: var(--status-danger); +} + +#user-context-vc-staff--mute-2h[class*="focused"] { + background-color: var(--menu-item-danger-hover-bg); + color: white; +} + +#user-context-vc-staff--mute-custom { + color: var(--status-danger); +} + +#user-context-vc-staff--mute-custom[class*="focused"] { + background-color: var(--menu-item-danger-hover-bg); + color: white; +} + +.vc-punishcommands-reason { + margin: 20px; + min-width: 500px; +} + +.vc-punishcommands-button-container * { + margin-left: auto; + margin-right: 20px; + margin-bottom: 20px; +} + +.vc-punishcommands-duration-c { + margin-top: 20px; + margin-bottom: 10px; + min-width: 500px; + margin-left: 20px; + margin-right: 20px; +} + +.vc-punishcommands-reason-c { + margin-bottom: 20px; + min-width: 500px; + margin-left: 20px; + margin-right: 20px; +} +