userflags/index.tsx

125 lines
4.2 KiB
TypeScript
Raw Normal View History

2024-10-12 12:39:41 -04:00
/*
* 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";
2024-10-06 15:01:19 -04:00
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
2024-10-12 12:39:41 -04:00
import { React, Text } from "@webpack/common";
import { Message } from "discord-types/general";
const flags = new Map<string, Flag>();
type Flag = {
type: "danger" | "warning" | "info" | "positive";
text: string;
};
function Flag({ message }: { message: Message; }) {
if (message.author.id === "886685857560539176") return (
<div>
<Text color="text-danger" variant="text-sm/semibold">
🛑 This link is explosive
</Text>
</div>
);
}
2024-10-06 15:01:19 -04:00
export default definePlugin({
name: "UserFlags",
2024-10-12 12:39:41 -04:00
description: `Add "flags" to users that will always show under their messages`,
2024-10-06 15:01:19 -04:00
authors: [Devs.nin0dev],
2024-10-12 12:39:41 -04:00
dependencies: ["MessageAccessoriesAPI"],
start() {
addAccessory("flag", (props: Record<string, any>) => {
return (
<Flag message={props.message as Message} />
);
}, 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;
}
}
]
2024-10-06 15:01:19 -04:00
});