mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 16:28:16 +00:00
MessageTags: rename to CustomCommands & fix some logic errors
This commit is contained in:
parent
f261a75cd5
commit
355b78a52d
5 changed files with 20 additions and 14 deletions
|
|
@ -17,7 +17,7 @@ import { Paragraph } from "@components/Paragraph";
|
|||
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { TextArea, TextInput, useState } from "@webpack/common";
|
||||
|
||||
import { parseTagArguments, registerTagCommand } from ".";
|
||||
import { parseTagArguments } from ".";
|
||||
import { addTag, getTag, Tag } from "./settings";
|
||||
|
||||
export function openCreateTagModal(initialValue: Tag = { name: "", message: "" }) {
|
||||
|
|
@ -120,7 +120,6 @@ function Modal({ initialValue, modalProps }: { initialValue: Tag; modalProps: Mo
|
|||
onClick={() => {
|
||||
const tag = { name, message };
|
||||
addTag(tag);
|
||||
registerTagCommand(tag);
|
||||
modalProps.onClose();
|
||||
}}
|
||||
disabled={!name || !message || hasReservedEphemeral}
|
||||
|
|
@ -23,7 +23,7 @@ export function SettingsTagList() {
|
|||
<BaseText size="md" weight="semibold">Registered Tags</BaseText>
|
||||
<Flex flexDirection="column" gap="0.5em" className={Margins.top8}>
|
||||
{Object.values(tagsList).map(tag => (
|
||||
<Card key={tag.name} className="vc-messageTags-card">
|
||||
<Card key={tag.name} className="vc-customCommands-card">
|
||||
<Paragraph size="md" weight="medium">{tag.name}</Paragraph>
|
||||
|
||||
<Button variant="secondary" size="iconOnly" onClick={() => openCreateTagModal(tag)}>
|
||||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
import "./styles.css";
|
||||
|
||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "@api/Commands";
|
||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage } from "@api/Commands";
|
||||
import { migratePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { sendMessage } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
|
|
@ -26,7 +27,7 @@ import definePlugin from "@utils/types";
|
|||
import { openCreateTagModal } from "./CreateTagModal";
|
||||
import { getTag, getTags, removeTag, settings, Tag } from "./settings";
|
||||
|
||||
const MessageTagsMarker = Symbol("MessageTags");
|
||||
const CustomCommandsMarker = Symbol("CustomCommands");
|
||||
const ArgumentRegex = /{{(.+?)}}/g;
|
||||
|
||||
export function parseTagArguments(message: string) {
|
||||
|
|
@ -79,16 +80,17 @@ export function registerTagCommand(tag: Tag) {
|
|||
const doSend = ephemeral ? sendBotMessage : sendMessage;
|
||||
doSend(ctx.channel.id, { content: response });
|
||||
},
|
||||
[MessageTagsMarker]: true,
|
||||
}, "CustomTags");
|
||||
[CustomCommandsMarker]: true,
|
||||
}, "CustomCommands");
|
||||
}
|
||||
|
||||
|
||||
|
||||
migratePluginSettings("CustomCommands", "MessageTags");
|
||||
export default definePlugin({
|
||||
name: "MessageTags",
|
||||
description: "Allows you to create custom slash commands",
|
||||
authors: [Devs.Luna, Devs.Ven],
|
||||
name: "CustomCommands",
|
||||
description: "Allows you to create custom slash commands / tags",
|
||||
tags: ["MessageTags"],
|
||||
authors: [Devs.Ven, Devs.Luna,],
|
||||
settings,
|
||||
|
||||
async start() {
|
||||
|
|
@ -101,7 +103,7 @@ export default definePlugin({
|
|||
commands: [
|
||||
{
|
||||
name: "tags",
|
||||
description: "Manage all the tags for yourself",
|
||||
description: "Manage all custom commands",
|
||||
inputType: ApplicationCommandInputType.BUILT_IN,
|
||||
options: [
|
||||
{
|
||||
|
|
@ -145,7 +147,6 @@ export default definePlugin({
|
|||
content: `A Tag with the name **${name}** does not exist!`
|
||||
});
|
||||
|
||||
unregisterCommand(name);
|
||||
removeTag(name);
|
||||
|
||||
sendBotMessage(ctx.channel.id, {
|
||||
|
|
@ -4,9 +4,11 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { unregisterCommand } from "@api/Commands";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { OptionType } from "@utils/types";
|
||||
|
||||
import { registerTagCommand } from ".";
|
||||
import { SettingsTagList } from "./SettingsTagList";
|
||||
|
||||
export const settings = definePluginSettings({
|
||||
|
|
@ -34,9 +36,13 @@ export function getTag(name: string) {
|
|||
}
|
||||
|
||||
export function addTag(tag: Tag) {
|
||||
unregisterCommand(tag.name);
|
||||
|
||||
settings.store.tagsList[tag.name] = tag;
|
||||
registerTagCommand(tag);
|
||||
}
|
||||
|
||||
export function removeTag(name: string) {
|
||||
delete settings.store.tagsList[name];
|
||||
unregisterCommand(name);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
.vc-messageTags-card {
|
||||
.vc-customCommands-card {
|
||||
padding: 0.5em;
|
||||
padding-left: 1em;
|
||||
display: grid;
|
||||
Loading…
Add table
Reference in a new issue