From 67314116c6a80e7dd45971d33eff85fa26771ab8 Mon Sep 17 00:00:00 2001 From: nin0dev Date: Sat, 12 Oct 2024 12:39:41 -0400 Subject: [PATCH] feat: flag commands --- index.tsx | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/index.tsx b/index.tsx index b36ca36..98cf7a4 100644 --- a/index.tsx +++ b/index.tsx @@ -1,9 +1,124 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, sendBotMessage } from "@api/Commands"; +import { addAccessory } from "@api/MessageAccessories"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; +import { React, Text } from "@webpack/common"; +import { Message } from "discord-types/general"; + +const flags = new Map(); +type Flag = { + type: "danger" | "warning" | "info" | "positive"; + text: string; +}; + +function Flag({ message }: { message: Message; }) { + if (message.author.id === "886685857560539176") return ( +
+ + 🛑 This link is explosive + +
+ ); +} export default definePlugin({ name: "UserFlags", - description: "Add "flags" to users that will always show under their messages", + description: `Add "flags" to users that will always show under their messages`, authors: [Devs.nin0dev], + dependencies: ["MessageAccessoriesAPI"], + start() { + addAccessory("flag", (props: Record) => { + return ( + + ); + }, 4); + }, + commands: [ + { + name: "flag set", + description: "Set a flag on a user", + inputType: ApplicationCommandInputType.BOT, + options: [ + { + name: "user", + type: ApplicationCommandOptionType.USER, + description: "The user to set a flag to", + required: true + }, + { + "name": "type", + "type": ApplicationCommandOptionType.STRING, + "description": "The type of flag to add", + choices: [ + { + label: "Danger", + value: "danger", + name: "Danger" + }, + { + label: "Warning", + value: "warning", + name: "Warning" + }, + { + label: "Info", + value: "info", + name: "Info" + }, + { + label: "Positive", + value: "positive", + name: "Positive" + } + ], + required: true + }, + { + name: "message", + type: ApplicationCommandOptionType.STRING, + description: "The flag content", + required: true + }, + ], + execute: (args: Argument[], ctx: CommandContext) => { + flags.set(args[0].value, { + type: args[1].value as "danger" | "warning" | "info" | "positive", + text: args[2].value + }); + sendBotMessage(ctx.channel.id, { + content: `Flag added to <@${args[0].value}> with content \`${args[2].value}\`!` + }); + console.log(flags); + return; + } + }, + { + name: "flag delete", + description: "Delete the flag from a user", + inputType: ApplicationCommandInputType.BOT, + options: [ + { + name: "user", + type: ApplicationCommandOptionType.USER, + description: "The user to delete the flag from", + required: true + } + ], + execute: (args: Argument[], ctx: CommandContext) => { + flags.delete(args[0].value); + sendBotMessage(ctx.channel.id, { + content: `Flag removed from <@${args[0].value}>` + }); + console.log(flags); + return; + } + } + ] });