feat: flag commands
This commit is contained in:
parent
bccdacf2e3
commit
67314116c6
1 changed files with 116 additions and 1 deletions
117
index.tsx
117
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<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>
|
||||
);
|
||||
}
|
||||
|
||||
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<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;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue