Signature Fixes

This commit is contained in:
thororen1234 2024-11-20 17:27:44 -05:00
parent 026befec32
commit 656a0168cc
2 changed files with 13 additions and 13 deletions

View file

@ -6,8 +6,7 @@
import "./style.css";
import { MessageEvents } from "@api/index";
import { MessageExtra, MessageObject } from "@api/MessageEvents";
import { addPreSendListener, MessageExtra, MessageObject, removePreSendListener } from "@api/MessageEvents";
import { EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
import { Forms } from "@webpack/common";
@ -23,6 +22,6 @@ export default definePlugin({
We can't guarantee this plugin won't get you warned or banned.
</Forms.FormText>
</>,
start: () => MessageEvents.addPreSendListener(handleMessage),
stop: () => MessageEvents.removePreSendListener(handleMessage)
start: () => addPreSendListener(handleMessage),
stop: () => removePreSendListener(handleMessage)
});

View file

@ -7,13 +7,12 @@
import { addChatBarButton, ChatBarButton, removeChatBarButton } from "@api/ChatButtons";
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { MessageEvents } from "@api/index";
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { Menu, React } from "@webpack/common";
// Big thank you too slientTyping
const settings = definePluginSettings(
@ -66,8 +65,13 @@ const SignatureToggle: ChatBarButton = ({ isMainChat }) => {
);
};
// Big thank you @thororen (discord) who helped me write this const
const handleMessage = ((channelId, msg) => { if (!settings.store.isEnabled) return ""; return msg.content = textProcessing(msg.content); });
const handleMessage = ((channelId, msg) => {
if (!settings.store.isEnabled) {
msg.content = msg.content;
} else {
msg.content = textProcessing(msg.content);
}
});
const ChatBarContextCheckbox: NavContextMenuPatchCallback = children => {
const { isEnabled, contextMenu } = settings.use(["isEnabled", "contextMenu"]);
@ -89,7 +93,6 @@ const ChatBarContextCheckbox: NavContextMenuPatchCallback = children => {
);
};
// This is usless for the normal user but is helpful for development since I decided to rework to plugin
migratePluginSettings("Signature", "SentVia");
export default definePlugin({
@ -103,14 +106,12 @@ export default definePlugin({
start: () => {
if (settings.store.isEnabled) true;
addChatBarButton("Signature", SignatureToggle);
// @ts-ignore
MessageEvents.addPreSendListener(handleMessage);
addPreSendListener(handleMessage);
},
stop: () => {
if (settings.store.isEnabled) false;
removeChatBarButton("Signature");
// @ts-ignore
MessageEvents.removePreSendListener(handleMessage);
removePreSendListener(handleMessage);
},