From eac866a505a800e9514d1eb5f1d324bb3b957fd5 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 24 Apr 2026 12:46:27 -0400 Subject: [PATCH] BlockKrisp: Fix Null --- src/equicordplugins/blockKrisp/index.ts | 4 +- .../commandPalette/actions/executors.ts | 212 ------------------ .../extensions/actions/holyNotes.ts | 161 ------------- .../commandPalette/extensions/catalog.ts | 12 - .../commandPalette/extensions/providers.ts | 6 - 5 files changed, 2 insertions(+), 393 deletions(-) delete mode 100644 src/equicordplugins/commandPalette/extensions/actions/holyNotes.ts diff --git a/src/equicordplugins/blockKrisp/index.ts b/src/equicordplugins/blockKrisp/index.ts index 9b80b65e8..2b621b4d6 100644 --- a/src/equicordplugins/blockKrisp/index.ts +++ b/src/equicordplugins/blockKrisp/index.ts @@ -25,8 +25,8 @@ export default definePlugin({ { find: "krisp_browser_models", replacement: { - match: /(\i,\{\i:\(\)=>)\i/, - replace: "$1null" + match: /if\(this._noiseCancellation\)/, + replace: "if(false)" } }, // Set Krisp to not supported diff --git a/src/equicordplugins/commandPalette/actions/executors.ts b/src/equicordplugins/commandPalette/actions/executors.ts index eee6f90e6..3680a27e4 100644 --- a/src/equicordplugins/commandPalette/actions/executors.ts +++ b/src/equicordplugins/commandPalette/actions/executors.ts @@ -7,8 +7,6 @@ import { isPluginEnabled, plugins } from "@api/PluginManager"; import { NotesIcon } from "@components/Icons"; import { toggleEnabled } from "@equicordplugins/equicordHelper/utils"; -import { noteHandler } from "@equicordplugins/holyNotes/NoteHandler"; -import type { Note } from "@equicordplugins/holyNotes/types"; import type { ScheduledMessage } from "@equicordplugins/scheduledMessages/types"; import { addScheduledMessage, getChannelDisplayInfo, getScheduledMessages, removeScheduledMessage, sendScheduledMessageNow, updateScheduledMessageTime } from "@equicordplugins/scheduledMessages/utils"; import { sleep } from "@utils/misc"; @@ -21,17 +19,11 @@ import { DISCORD_INTERNAL_HOSTS, executeCommand, getCommandById } from "../regis import { makeIconFromUrl } from "../ui/iconFromUrl"; import { sendMessageToChannel, sendMessageToUser } from "./sendMessageAction"; -interface ResolvedHolyNote { - notebook: string; - note: Note; -} - interface StagedRescheduledMessage { id: string; label: string; } -let stagedMoveNote: ResolvedHolyNote | null = null; let stagedRescheduleMessage: StagedRescheduledMessage | null = null; let pendingCancelScheduledMessageId: string | null = null; @@ -559,198 +551,6 @@ function filterScheduledMessages(target: string): ScheduledMessage[] { }); } -function getNotebookNames(): string[] { - return Object.keys(noteHandler.getAllNotes()); -} - -function filterNotebookNames(target: string, includeMain: boolean): string[] { - const normalizedTarget = normalizeText(target); - return getNotebookNames() - .filter(notebook => includeMain || notebook !== "Main") - .filter(notebook => !normalizedTarget || notebook.toLowerCase().includes(normalizedTarget)) - .sort((left, right) => left.localeCompare(right)); -} - -function getResolvedNotes(target: string): ResolvedHolyNote[] { - const normalizedTarget = normalizeText(target); - const notebooks = noteHandler.getAllNotes(); - const resolved: ResolvedHolyNote[] = []; - - for (const [notebook, notes] of Object.entries(notebooks)) { - for (const note of Object.values(notes)) { - const content = note.content?.trim() ?? ""; - if (normalizedTarget && !content.toLowerCase().includes(normalizedTarget)) continue; - resolved.push({ notebook, note }); - } - } - - return resolved; -} - -function toNoteSnippet(note: Note): string { - const content = note.content?.replace(/\s+/g, " ").trim(); - if (!content) return "(No text)"; - if (content.length <= 56) return content; - return `${content.slice(0, 53)}...`; -} - -function buildCreateNotebookCandidates(target: string): QueryActionCandidate[] { - const notebookName = target.trim(); - if (!notebookName) { - return [{ - id: "query-create-notebook-invalid", - label: "Create notebook", - description: "Notebook name is required.", - badge: "Query", - icon: NotesIcon, - run: () => { - showToast("Notebook name is required.", Toasts.Type.FAILURE); - return false; - } - }]; - } - - return [{ - id: `query-create-notebook-${notebookName.toLowerCase()}`, - label: `Create notebook ${notebookName}`, - badge: "Query", - icon: NotesIcon, - run: async () => { - if (!await ensureHolyNotesEnabled()) return false; - if (noteHandler.getNotes(notebookName)) { - showToast(`Notebook ${notebookName} already exists`, Toasts.Type.FAILURE); - return false; - } - noteHandler.newNoteBook(notebookName); - } - }]; -} - -function buildDeleteNotebookCandidates(target: string): QueryActionCandidate[] { - const notebooks = filterNotebookNames(target, false); - if (notebooks.length === 0) { - return [{ - id: "query-delete-notebook-none", - label: "Delete notebook", - description: "No deletable notebook found.", - badge: "Query", - icon: NotesIcon, - run: () => { - showToast("No deletable notebook found.", Toasts.Type.MESSAGE); - return false; - } - }]; - } - - return notebooks.slice(0, 8).map(notebook => ({ - id: `query-delete-notebook-${notebook.toLowerCase()}`, - label: notebook, - description: "Notebook", - badge: "Query", - icon: NotesIcon, - run: async () => { - if (!await ensureHolyNotesEnabled()) return false; - noteHandler.deleteNotebook(notebook); - } - })); -} - -function buildJumpNoteCandidates(target: string): QueryActionCandidate[] { - const notes = getResolvedNotes(target).slice(0, 10); - if (notes.length === 0) { - return [{ - id: "query-jump-note-none", - label: "Jump to note", - description: "No matching note found.", - badge: "Query", - icon: NotesIcon, - run: () => { - showToast("No matching note found.", Toasts.Type.FAILURE); - return false; - } - }]; - } - - return notes.map(({ notebook, note }) => ({ - id: `query-jump-note-${notebook}-${note.id}`, - label: `[${notebook}] ${toNoteSnippet(note)}`, - description: "Open original message.", - badge: "Query", - icon: NotesIcon, - run: async () => { - if (!await ensureHolyNotesEnabled()) return false; - NavigationRouter.transitionTo(`/channels/${note.guild_id || "@me"}/${note.channel_id}/${note.id}`); - } - })); -} - -function buildMoveNoteCandidates(target: string): QueryActionCandidate[] { - if (stagedMoveNote) { - const destinationNotebooks = filterNotebookNames(target, true) - .filter(notebook => notebook !== stagedMoveNote?.notebook); - - if (destinationNotebooks.length === 0) { - return [{ - id: "query-move-note-no-destination", - label: "Move note", - description: "No destination notebook found.", - badge: "Query", - icon: NotesIcon, - run: () => { - showToast("No destination notebook found.", Toasts.Type.FAILURE); - return false; - } - }]; - } - - return destinationNotebooks.slice(0, 8).map(destinationNotebook => ({ - id: `query-move-note-destination-${destinationNotebook.toLowerCase()}`, - label: `[${stagedMoveNote!.notebook}] ${toNoteSnippet(stagedMoveNote!.note)} -> Move to ${destinationNotebook}`, - description: "Move note", - badge: "Query", - icon: NotesIcon, - run: async () => { - if (!stagedMoveNote) return; - if (!await ensureHolyNotesEnabled()) return false; - if (!stagedMoveNote) return; - noteHandler.moveNote(stagedMoveNote.note, stagedMoveNote.notebook, destinationNotebook); - stagedMoveNote = null; - } - })); - } - - const notes = getResolvedNotes(target).slice(0, 10); - if (notes.length === 0) { - return [{ - id: "query-move-note-none", - label: "Move note", - description: "No matching note found.", - badge: "Query", - icon: NotesIcon, - run: () => { - showToast("No matching note found.", Toasts.Type.FAILURE); - return false; - } - }]; - } - - return notes.map(({ notebook, note }) => ({ - id: `query-move-note-select-${notebook}-${note.id}`, - label: `[${notebook}] ${toNoteSnippet(note)}`, - description: "Select destination notebook.", - badge: "Query", - icon: NotesIcon, - run: () => { - return ensureHolyNotesEnabled().then(enabled => { - if (!enabled) return false; - stagedMoveNote = { notebook, note }; - showToast("Note selected. Choose destination notebook.", Toasts.Type.MESSAGE); - return false; - }); - } - })); -} - function buildQuickScheduleMessageCandidates(target: string): QueryActionCandidate[] { const parsed = parseQuickScheduleTarget(target); if (!parsed) return []; @@ -926,15 +726,11 @@ function buildCancelScheduledMessageCandidates(target: string): QueryActionCandi export function buildQueryResolution(query: string): QueryResolution { const parsed = parseQuery(query); if (!parsed) { - stagedMoveNote = null; stagedRescheduleMessage = null; pendingCancelScheduledMessageId = null; return { type: "none" }; } - if (parsed.intent !== "move_note") { - stagedMoveNote = null; - } if (parsed.intent !== "reschedule_message") { stagedRescheduleMessage = null; } @@ -971,14 +767,6 @@ export function buildQueryResolution(query: string): QueryResolution { return { type: "candidates", candidates: buildTogglePluginCandidates(parsed.target) }; case "open_url": return { type: "candidates", candidates: buildOpenUrlCandidates(parsed.target) }; - case "create_notebook": - return { type: "candidates", candidates: buildCreateNotebookCandidates(parsed.target) }; - case "delete_notebook": - return { type: "candidates", candidates: buildDeleteNotebookCandidates(parsed.target) }; - case "move_note": - return { type: "candidates", candidates: buildMoveNoteCandidates(parsed.target) }; - case "jump_note": - return { type: "candidates", candidates: buildJumpNoteCandidates(parsed.target) }; case "schedule_message": return { type: "candidates", candidates: buildQuickScheduleMessageCandidates(parsed.target) }; case "reschedule_message": diff --git a/src/equicordplugins/commandPalette/extensions/actions/holyNotes.ts b/src/equicordplugins/commandPalette/extensions/actions/holyNotes.ts deleted file mode 100644 index 7b41380e2..000000000 --- a/src/equicordplugins/commandPalette/extensions/actions/holyNotes.ts +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2026 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { isPluginEnabled, plugins } from "@api/PluginManager"; -import { toggleEnabled } from "@equicordplugins/equicordHelper/utils"; -import { noteHandler } from "@equicordplugins/holyNotes/NoteHandler"; -import { Message } from "@vencord/discord-types"; -import { MessageStore, SelectedChannelStore, Toasts } from "@webpack/common"; - -import { DEFAULT_CATEGORY_ID } from "../../metadata/categories"; -import { TAG_NAVIGATION, TAG_PLUGINS, TAG_UTILITY } from "../../metadata/tags"; -import type { CommandEntry } from "../../registry"; -import type { HolyNotesPlugin } from "../types"; - -function showToast(message: string, type: (typeof Toasts.Type)[keyof typeof Toasts.Type]) { - Toasts.show({ message, type, id: Toasts.genId(), options: { position: Toasts.Position.BOTTOM } }); -} - -function getHolyNotesPlugin(): HolyNotesPlugin | null { - const plugin = plugins.HolyNotes as HolyNotesPlugin | undefined; - return plugin ?? null; -} - -async function ensureHolyNotesPluginEnabled() { - const plugin = getHolyNotesPlugin(); - if (!plugin) { - showToast("HolyNotes plugin is unavailable.", Toasts.Type.FAILURE); - return false; - } - - if (isPluginEnabled(plugin.name)) return true; - - const success = await toggleEnabled(plugin.name); - if (!success || !isPluginEnabled(plugin.name)) { - showToast("Failed to enable HolyNotes.", Toasts.Type.FAILURE); - return false; - } - - showToast("Enabled HolyNotes.", Toasts.Type.SUCCESS); - return true; -} - -async function runHolyNotesOpen() { - if (!await ensureHolyNotesPluginEnabled()) return; - - const plugin = getHolyNotesPlugin(); - const openNotes = plugin?.toolboxActions?.["Open Notes"]; - if (typeof openNotes !== "function") { - showToast("HolyNotes action is unavailable.", Toasts.Type.FAILURE); - return; - } - - await Promise.resolve(openNotes()); -} - -function getLastNonSystemMessageInChannel(channelId: string): Message | null { - const messageCollection = MessageStore.getMessages?.(channelId) as { _array?: Message[]; } | undefined; - const messages = messageCollection?._array; - if (!messages?.length) return null; - - for (let index = messages.length - 1; index >= 0; index--) { - const message = messages[index] as Message & { deleted?: boolean; type?: number; }; - if (!message || message.deleted) continue; - if (typeof message.type === "number" && message.type !== 0) continue; - return message; - } - - return null; -} - -async function runHolyNotesQuickSaveLastMessage() { - if (!await ensureHolyNotesPluginEnabled()) return; - - const channelId = SelectedChannelStore.getChannelId(); - if (!channelId) { - showToast("No active channel available.", Toasts.Type.FAILURE); - return; - } - - const message = getLastNonSystemMessageInChannel(channelId); - if (!message) { - showToast("No message available to save.", Toasts.Type.MESSAGE); - return; - } - - noteHandler.addNote(message, "Main"); -} - -export function createHolyNotesExtensionCommands(): CommandEntry[] { - return [ - { - id: "extension-holy-notes-open", - label: "Open Notes", - description: "Open the HolyNotes notebook modal.", - keywords: ["holy", "notes", "notebook", "bookmark", "open", "plugin", "extension"], - categoryId: DEFAULT_CATEGORY_ID, - tags: [TAG_PLUGINS, TAG_UTILITY, TAG_NAVIGATION], - handler: runHolyNotesOpen - }, - { - id: "extension-holy-notes-create-notebook-query", - label: "Create Notebook", - description: "Create a HolyNotes notebook.", - keywords: ["holy", "notes", "notebook", "create", "new", "plugin", "extension"], - categoryId: DEFAULT_CATEGORY_ID, - tags: [TAG_PLUGINS, TAG_UTILITY], - closeAfterExecute: true, - queryTemplate: "create notebook ", - queryPlaceholder: "Notebook name", - handler: () => undefined - }, - { - id: "extension-holy-notes-delete-notebook-query", - label: "Delete Notebook", - description: "Delete a HolyNotes notebook.", - keywords: ["holy", "notes", "notebook", "delete", "remove", "plugin", "extension"], - categoryId: DEFAULT_CATEGORY_ID, - tags: [TAG_PLUGINS, TAG_UTILITY], - closeAfterExecute: true, - queryTemplate: "delete notebook ", - queryPlaceholder: "Notebook name", - handler: () => undefined - }, - { - id: "extension-holy-notes-move-note-query", - label: "Move Note", - description: "Move a HolyNotes note to another notebook.", - keywords: ["holy", "notes", "note", "move", "notebook", "plugin", "extension"], - categoryId: DEFAULT_CATEGORY_ID, - tags: [TAG_PLUGINS, TAG_UTILITY], - closeAfterExecute: true, - queryTemplate: "move note ", - queryPlaceholder: "Find note by content, then destination", - handler: () => undefined - }, - { - id: "extension-holy-notes-jump-note-query", - label: "Jump To Note", - description: "Jump to the original message for a HolyNotes note.", - keywords: ["holy", "notes", "jump", "note", "message", "plugin", "extension"], - categoryId: DEFAULT_CATEGORY_ID, - tags: [TAG_PLUGINS, TAG_NAVIGATION], - closeAfterExecute: true, - queryTemplate: "jump to note ", - queryPlaceholder: "Search note content", - handler: () => undefined - }, - { - id: "extension-holy-notes-quick-save-last-message", - label: "Quick Save Last Message", - description: "Save the latest message in this channel to Main.", - keywords: ["holy", "notes", "save", "last", "message", "bookmark", "main", "plugin", "extension"], - categoryId: DEFAULT_CATEGORY_ID, - tags: [TAG_PLUGINS, TAG_UTILITY], - handler: runHolyNotesQuickSaveLastMessage - } - ]; -} diff --git a/src/equicordplugins/commandPalette/extensions/catalog.ts b/src/equicordplugins/commandPalette/extensions/catalog.ts index 6e13217fd..68c5ca40f 100644 --- a/src/equicordplugins/commandPalette/extensions/catalog.ts +++ b/src/equicordplugins/commandPalette/extensions/catalog.ts @@ -69,18 +69,6 @@ export const EXTENSIONS_CATALOG: ExtensionDefinition[] = [ tags: [TAG_PLUGINS, TAG_UTILITY], keywords: ["extension", "plugin", "random", "voice", "join", "channel", "vc"] }, - { - id: HOLY_NOTES_EXTENSION_ID, - label: "HolyNotes", - description: "Control HolyNotes from the command palette.", - detailCategoryId: HOLY_NOTES_EXTENSION_DETAIL_CATEGORY_ID, - commandId: "extension-holy-notes-open", - commandLabel: "Open Notes", - commandDescription: "Open the HolyNotes notebook modal.", - sourcePath: "src/equicordplugins/holyNotes", - tags: [TAG_PLUGINS, TAG_UTILITY], - keywords: ["extension", "plugin", "holy", "notes", "notebook", "bookmark"] - }, { id: SILENT_MESSAGE_TOGGLE_EXTENSION_ID, label: "SilentMessageToggle", diff --git a/src/equicordplugins/commandPalette/extensions/providers.ts b/src/equicordplugins/commandPalette/extensions/providers.ts index fbf72664b..30dd6f894 100644 --- a/src/equicordplugins/commandPalette/extensions/providers.ts +++ b/src/equicordplugins/commandPalette/extensions/providers.ts @@ -9,7 +9,6 @@ import { Toasts } from "@webpack/common"; import { TAG_DEVELOPER, TAG_NAVIGATION, TAG_PLUGINS, TAG_UTILITY } from "../metadata/tags"; import type { CommandEntry, ExtensionDefinition } from "../registry"; -import { createHolyNotesExtensionCommands } from "./actions/holyNotes"; import { createRandomVoiceExtensionCommand } from "./actions/randomVoice"; import { createScheduledMessagesExtensionCommands } from "./actions/scheduledMessages"; import { createSilentMessageToggleExtensionCommand } from "./actions/silentMessageToggle"; @@ -19,7 +18,6 @@ import { EXTENSIONS_CATALOG_CATEGORY_ID, EXTENSIONS_DETAIL_PROVIDER_ID, EXTENSIONS_PACK_PROVIDER_ID, - HOLY_NOTES_EXTENSION_ID, RANDOM_VOICE_EXTENSION_ID, SCHEDULED_MESSAGES_EXTENSION_ID, SILENT_MESSAGE_TOGGLE_EXTENSION_ID, @@ -55,10 +53,6 @@ function createInstalledExtensionCommands(extensionsState: ExtensionsState): Com entries.push(createRandomVoiceExtensionCommand(extensionsState.extensionKeybinds)); } - if (extensionsState.installedExtensionIds.has(HOLY_NOTES_EXTENSION_ID)) { - entries.push(...createHolyNotesExtensionCommands()); - } - if (extensionsState.installedExtensionIds.has(SILENT_MESSAGE_TOGGLE_EXTENSION_ID)) { entries.push(createSilentMessageToggleExtensionCommand(extensionsState.extensionKeybinds)); }