diff --git a/src/equicordplugins/baseDecoder/index.tsx b/src/equicordplugins/baseDecoder/index.tsx index b2febc025..8508dd465 100644 --- a/src/equicordplugins/baseDecoder/index.tsx +++ b/src/equicordplugins/baseDecoder/index.tsx @@ -112,42 +112,45 @@ export default definePlugin({ authors: [EquicordDevs.ThePirateStoner], dependencies: ["MessagePopoverAPI"], settings, - renderMessagePopoverButton(msg) { - const handleClick = () => { - const base64Strings = findBase64Strings(msg.content); - const decodedContent = decodeBase64Strings(base64Strings); - if (settings.store.clickMethod === "Right") { - decodedContent.forEach(content => copyWithToast(content)); - } else { - openDecodedBase64Modal(decodedContent); - } - }; + messagePopoverButton: { + icon: DecodeIcon, + render(msg) { + const handleClick = () => { + const base64Strings = findBase64Strings(msg.content); + const decodedContent = decodeBase64Strings(base64Strings); + if (settings.store.clickMethod === "Right") { + decodedContent.forEach(content => copyWithToast(content)); + } else { + openDecodedBase64Modal(decodedContent); + } + }; - const handleContextMenu = e => { - const base64Strings = findBase64Strings(msg.content); - const decodedContent = decodeBase64Strings(base64Strings); - if (settings.store.clickMethod === "Left") { - e.preventDefault(); - e.stopPropagation(); - decodedContent.forEach(content => copyWithToast(content)); - } else { - e.preventDefault(); - e.stopPropagation(); - openDecodedBase64Modal(decodedContent); - } - }; + const handleContextMenu = e => { + const base64Strings = findBase64Strings(msg.content); + const decodedContent = decodeBase64Strings(base64Strings); + if (settings.store.clickMethod === "Left") { + e.preventDefault(); + e.stopPropagation(); + decodedContent.forEach(content => copyWithToast(content)); + } else { + e.preventDefault(); + e.stopPropagation(); + openDecodedBase64Modal(decodedContent); + } + }; - const label = settings.store.clickMethod === "Right" - ? "Copy Decoded (Left Click) / Decode Base64 (Right Click)" - : "Decode Base64 (Left Click) / Copy Decoded (Right Click)"; + const label = settings.store.clickMethod === "Right" + ? "Copy Decoded (Left Click) / Decode Base64 (Right Click)" + : "Decode Base64 (Left Click) / Copy Decoded (Right Click)"; - return { - label, - icon: DecodeIcon, - message: msg, - channel: ChannelStore.getChannel(msg.channel_id), - onClick: handleClick, - onContextMenu: handleContextMenu - }; + return { + label, + icon: DecodeIcon, + message: msg, + channel: ChannelStore.getChannel(msg.channel_id), + onClick: handleClick, + onContextMenu: handleContextMenu + }; + } } }); diff --git a/src/equicordplugins/equicordToolbox/menu.tsx b/src/equicordplugins/equicordToolbox/menu.tsx index f229b0227..1f2f45057 100644 --- a/src/equicordplugins/equicordToolbox/menu.tsx +++ b/src/equicordplugins/equicordToolbox/menu.tsx @@ -226,7 +226,7 @@ export function buildThemeMenuEntries() { { if (enabledThemes.includes(theme.fileName)) { diff --git a/src/equicordplugins/findReply/index.tsx b/src/equicordplugins/findReply/index.tsx index b5d4d0f3c..5f83dfbc3 100644 --- a/src/equicordplugins/findReply/index.tsx +++ b/src/equicordplugins/findReply/index.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover"; +import { removeMessagePopoverButton } from "@api/MessagePopover"; import { definePluginSettings } from "@api/Settings"; import { disableStyle, enableStyle } from "@api/Styles"; import { Devs } from "@utils/constants"; @@ -94,9 +94,9 @@ export default definePlugin({ description: "Jumps to the earliest reply to a message in a channel (lets you follow past conversations more easily).", authors: [Devs.newwares], settings, - start() { - enableStyle(styles); - addMessagePopoverButton("vc-findreply", message => { + messagePopoverButton: { + icon: FindReplyIcon, + render(message) { if (!message.id) return null; const replies = findReplies(message); if (settings.store.hideButtonIfNoReply && !replies.length) return null; @@ -148,7 +148,10 @@ export default definePlugin({ } } }; - }); + } + }, + start() { + enableStyle(styles); }, stop() { removeMessagePopoverButton("vc-findreply"); diff --git a/src/equicordplugins/holyNotes/index.tsx b/src/equicordplugins/holyNotes/index.tsx index 03c19229b..37d711f34 100644 --- a/src/equicordplugins/holyNotes/index.tsx +++ b/src/equicordplugins/holyNotes/index.tsx @@ -20,7 +20,7 @@ import "./style.css"; import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { DataStore } from "@api/index"; -import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover"; +import { removeMessagePopoverButton } from "@api/MessagePopover"; import ErrorBoundary from "@components/ErrorBoundary"; import { EquicordDevs } from "@utils/constants"; import { classes } from "@utils/misc"; @@ -112,11 +112,9 @@ export default definePlugin({ e.toolbar, ]; }, - async start() { - if (await DataStore.keys(HolyNoteStore).then(keys => !keys.includes("Main"))) return noteHandler.newNoteBook("Main"); - if (!noteHandlerCache.has("Main")) await DataStoreToCache(); - - addMessagePopoverButton("HolyNotes", message => { + messagePopoverButton: { + icon: NoteButtonPopover, + render(message) { return { label: "Save Note", icon: NoteButtonPopover, @@ -125,7 +123,11 @@ export default definePlugin({ onClick: () => noteHandler.addNote(message, "Main") }; - }); + } + }, + async start() { + if (await DataStore.keys(HolyNoteStore).then(keys => !keys.includes("Main"))) return noteHandler.newNoteBook("Main"); + if (!noteHandlerCache.has("Main")) await DataStoreToCache(); }, async stop() { diff --git a/src/equicordplugins/husk/index.tsx b/src/equicordplugins/husk/index.tsx index 9307c2109..11e3323d5 100644 --- a/src/equicordplugins/husk/index.tsx +++ b/src/equicordplugins/husk/index.tsx @@ -18,7 +18,6 @@ * along with this program. If not, see . */ -import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover"; import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; @@ -70,40 +69,44 @@ export function Husk(props: IconProps) { ); } +const settings = definePluginSettings({ + findInServer: { + description: "Attempt to find emoji of same name in server before using ID in settings (useful if no nitro)", + type: OptionType.BOOLEAN, + default: true + }, + emojiName: { + description: "Emoji name (default (from Vencord Server): husk)", + type: OptionType.STRING, + default: "husk" + }, + emojiID: { + description: "Emoji ID (default (from Vencord Server): 1026532993923293184)", + type: OptionType.BIGINT, + default: 1026532993923293184n + } +}); + +function getEmojiIdThatShouldBeUsed(guildId: string) { + if (!settings.store.findInServer || guildId === "") return settings.store.emojiID; + let id = ""; + EmojiStore.getGuildEmoji(guildId).forEach(emoji => { + if (emoji.name === settings.store.emojiName) { + id = emoji.id; + } + }); + return id !== "" ? id : settings.store.emojiID; +} + export default definePlugin({ name: "Husk", description: "Adds Husk button (check settings to change used emoji)", authors: [Devs.nin0dev], dependencies: ["MessagePopoverAPI"], - settings: definePluginSettings({ - findInServer: { - description: "Attempt to find emoji of same name in server before using ID in settings (useful if no nitro)", - type: OptionType.BOOLEAN, - default: true - }, - emojiName: { - description: "Emoji name (default (from Vencord Server): husk)", - type: OptionType.STRING, - default: "husk" - }, - emojiID: { - description: "Emoji ID (default (from Vencord Server): 1026532993923293184)", - type: OptionType.BIGINT, - default: 1026532993923293184n - } - }), - getEmojiIdThatShouldBeUsed(guildId: string) { - if (!this.settings.store.findInServer || guildId === "") return this.settings.store.emojiID; - let id = ""; - EmojiStore.getGuildEmoji(guildId).forEach(emoji => { - if (emoji.name === this.settings.store.emojiName) { - id = emoji.id; - } - }); - return id !== "" ? id : this.settings.store.emojiID; - }, - async start() { - addMessagePopoverButton("Husk", msg => { + settings, + messagePopoverButton: { + icon: Husk, + render(msg) { return { label: "Husk", icon: Husk, @@ -112,16 +115,11 @@ export default definePlugin({ onClick: () => { const guildId = ChannelStore.getChannel(msg.channel_id).guild_id !== null ? ChannelStore.getChannel(msg.channel_id).guild_id : ""; RestAPI.put({ - url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${this.settings.store.emojiName}:${this.getEmojiIdThatShouldBeUsed(guildId)}/@me` + url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${settings.store.emojiName}:${getEmojiIdThatShouldBeUsed(guildId)}/@me` } ); } }; - }); - }, - - stop() { - removeMessagePopoverButton("Husk"); - }, - + }, + } }); diff --git a/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx b/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx index 06b06a52f..b4946e28f 100644 --- a/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx +++ b/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx @@ -26,7 +26,7 @@ import { } from "@utils/modal"; import { Button, React, TextInput } from "@webpack/common"; -import invisibleChatDesktop, { decrypt } from "../index"; +import { buildEmbed, decrypt } from "../index"; export function DecModal(props: any) { const encryptedMessage: string = props?.message?.content; @@ -54,7 +54,7 @@ export function DecModal(props: any) { onClick={() => { const toSend = decrypt(encryptedMessage, password, true); if (!toSend || !props?.message) return; - invisibleChatDesktop.buildEmbed(props?.message, toSend); + buildEmbed(props?.message, toSend); props.onClose(); }}> Decrypt diff --git a/src/equicordplugins/invisibleChat.desktop/index.tsx b/src/equicordplugins/invisibleChat.desktop/index.tsx index e6ba63e45..37a14d4d2 100644 --- a/src/equicordplugins/invisibleChat.desktop/index.tsx +++ b/src/equicordplugins/invisibleChat.desktop/index.tsx @@ -98,6 +98,49 @@ const settings = definePluginSettings({ } }); +const EMBED_API_URL = "https://embed.sammcheese.net"; +const INV_REGEX = new RegExp(/( \u200c|\u200d |[\u2060-\u2064])[^\u200b]/); +const URL_REGEX = new RegExp(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/); +function colorCodeFromNumber(color: number): string { + return `#${[color >> 16, color >> 8, color] + .map(x => (x & 0xFF).toString(16)) + .join("")}`; +} + +async function getEmbed(url: URL): Promise { + const { body } = await RestAPI.post({ + url: Constants.Endpoints.UNFURL_EMBED_URLS, + body: { + urls: [url] + } + }); + // The endpoint returns the color as a number, but Discord expects a string + body.embeds[0].color = colorCodeFromNumber(body.embeds[0].color); + return await body.embeds[0]; +} + +export async function buildEmbed(message: any, revealed: string): Promise { + const urlCheck = revealed.match(URL_REGEX); + + message.embeds.push({ + type: "rich", + rawTitle: "Decrypted Message", + color: "#45f5f5", + rawDescription: revealed, + footer: { + text: "Made with ❤️ by c0dine and Sammy!", + }, + }); + + if (urlCheck?.length) { + const embed = await getEmbed(new URL(urlCheck[0])); + if (embed) + message.embeds.push(embed); + } + + updateMessage(message.channel_id, message.id, { embeds: message.embeds }); +} + export default definePlugin({ name: "InvisibleChat", description: "Encrypt your Messages in a non-suspicious way!", @@ -116,80 +159,35 @@ export default definePlugin({ } }, ], + INV_REGEX, - EMBED_API_URL: "https://embed.sammcheese.net", - INV_REGEX: new RegExp(/( \u200c|\u200d |[\u2060-\u2064])[^\u200b]/), - URL_REGEX: new RegExp( - /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/, - ), async start() { const { default: StegCloak } = await getStegCloak(); steggo = new StegCloak(true, false); }, - - renderMessagePopoverButton(message) { - return this.INV_REGEX.test(message?.content) - ? { - label: "Decrypt Message", - icon: this.popOverIcon, - message: message, - channel: ChannelStore.getChannel(message.channel_id), - onClick: async () => { - const res = await iteratePasswords(message); - - if (res) - this.buildEmbed(message, res); - else - buildDecModal({ message }); - } - } - : null; - }, - renderChatBarButton: ChatBarIcon, + messagePopoverButton: { + icon: PopOverIcon, + render(message) { + return INV_REGEX.test(message?.content) + ? { + label: "Decrypt Message", + icon: PopOverIcon, + message: message, + channel: ChannelStore.getChannel(message.channel_id), + onClick: async () => { + const res = await iteratePasswords(message); - colorCodeFromNumber(color: number): string { - return `#${[color >> 16, color >> 8, color] - .map(x => (x & 0xFF).toString(16)) - .join("")}`; - }, - - // Gets the Embed of a Link - async getEmbed(url: URL): Promise { - const { body } = await RestAPI.post({ - url: Constants.Endpoints.UNFURL_EMBED_URLS, - body: { - urls: [url] - } - }); - // The endpoint returns the color as a number, but Discord expects a string - body.embeds[0].color = this.colorCodeFromNumber(body.embeds[0].color); - return await body.embeds[0]; - }, - - async buildEmbed(message: any, revealed: string): Promise { - const urlCheck = revealed.match(this.URL_REGEX); - - message.embeds.push({ - type: "rich", - rawTitle: "Decrypted Message", - color: "#45f5f5", - rawDescription: revealed, - footer: { - text: "Made with ❤️ by c0dine and Sammy!", - }, - }); - - if (urlCheck?.length) { - const embed = await this.getEmbed(new URL(urlCheck[0])); - if (embed) - message.embeds.push(embed); + if (res) + buildEmbed(message, res); + else + buildDecModal({ message }); + } + } + : null; } - - updateMessage(message.channel_id, message.id, { embeds: message.embeds }); }, - popOverIcon: () => , indicator: ErrorBoundary.wrap(Indicator, { noop: true }) }); diff --git a/src/equicordplugins/repeatMessages/index.tsx b/src/equicordplugins/repeatMessages/index.tsx index 7f89ff3bb..1ab3a17d9 100644 --- a/src/equicordplugins/repeatMessages/index.tsx +++ b/src/equicordplugins/repeatMessages/index.tsx @@ -136,15 +136,18 @@ export default definePlugin({ contextMenus: { "message": messageCtxPatch }, - renderMessagePopoverButton(msg) { - if (!msg) return null; - return { - label: "Repeat (Click) / Repeat and Reply (Shift + Click)", - icon: RepeatMessageIcon, - message: msg, - channel: ChannelStore.getChannel(msg.channel_id), - onClick: async () => repeatMessage(msg) - }; + messagePopoverButton: { + icon: RepeatMessageIcon, + render(msg) { + if (!msg) return null; + return { + label: "Repeat (Click) / Repeat and Reply (Shift + Click)", + icon: RepeatMessageIcon, + message: msg, + channel: ChannelStore.getChannel(msg.channel_id), + onClick: async () => repeatMessage(msg) + }; + } }, start() { document.addEventListener("keyup", keyupListener); diff --git a/src/equicordplugins/soundBoardLogger/components/Icons.tsx b/src/equicordplugins/soundBoardLogger/components/Icons.tsx index 51bf3c9e3..fceeb8394 100644 --- a/src/equicordplugins/soundBoardLogger/components/Icons.tsx +++ b/src/equicordplugins/soundBoardLogger/components/Icons.tsx @@ -4,12 +4,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { ChatBarButton, ChatBarButtonFactory } from "@api/ChatButtons"; import { cl } from "@equicordplugins/soundBoardLogger/utils"; import { classes } from "@utils/misc"; import { Button, ButtonWrapperClasses, Tooltip } from "@webpack/common"; -import { openSoundBoardLog } from "./SoundBoardLog"; // Thanks svgrepo.com for the play and download icons. // Licensed under CC Attribution License https://www.svgrepo.com/page/licensing/#CC%20Attribution @@ -58,12 +56,8 @@ export function IconWithTooltip({ text, icon, onClick }) { ; } -export const ChatBarIcon: ChatBarButtonFactory = ({ isMainChat }) => { - if (!isMainChat) return null; - return ( - - - - ); +export const ChatBarIcon = () => { + return + + ; }; diff --git a/src/equicordplugins/soundBoardLogger/index.tsx b/src/equicordplugins/soundBoardLogger/index.tsx index 705bc9498..41aa76180 100644 --- a/src/equicordplugins/soundBoardLogger/index.tsx +++ b/src/equicordplugins/soundBoardLogger/index.tsx @@ -11,7 +11,7 @@ import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { FluxDispatcher } from "@webpack/common"; -import { ChatBarIcon } from "./components/Icons"; +import { CharBarButton, ChatBarIcon } from "./components/Icons"; import { OpenSBLogsButton } from "./components/SoundBoardLog"; import settings from "./settings"; import { updateLoggedSounds } from "./store"; @@ -56,7 +56,7 @@ export default definePlugin({ await updateLoggedSounds(sound); getListeners().forEach(cb => cb()); }); - if (settings.store.IconLocation === "chat") addChatBarButton("vc-soundlog-button", ChatBarIcon); + if (settings.store.IconLocation === "chat") addChatBarButton("vc-soundlog-button", CharBarButton, ChatBarIcon); }, stop() { disableStyle(styles); diff --git a/src/equicordplugins/translatePlus/index.tsx b/src/equicordplugins/translatePlus/index.tsx index ed130cc08..2457d0877 100644 --- a/src/equicordplugins/translatePlus/index.tsx +++ b/src/equicordplugins/translatePlus/index.tsx @@ -52,17 +52,18 @@ export default definePlugin({ contextMenus: { "message": messageCtxPatch }, - renderMessageAccessory: props => , - renderMessagePopoverButton: message => { - if (!message.content) return null; - - return { - label: "Translate", - icon: Icon, - message: message, - channel: ChannelStore.getChannel(message.channel_id), - onClick: () => handleTranslate(message), - }; - }, + messagePopoverButton: { + icon: Icon, + render(message) { + if (!message.content) return null; + return { + label: "Translate", + icon: Icon, + message: message, + channel: ChannelStore.getChannel(message.channel_id), + onClick: () => handleTranslate(message), + }; + } + } }); diff --git a/src/equicordplugins/translatePlus/utils/icon.tsx b/src/equicordplugins/translatePlus/utils/icon.tsx index f1bd55f4f..a5aa1f1dd 100644 --- a/src/equicordplugins/translatePlus/utils/icon.tsx +++ b/src/equicordplugins/translatePlus/utils/icon.tsx @@ -4,11 +4,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { cl, IconProps } from "@equicordplugins/translatePlus/misc/types"; +import { cl } from "@equicordplugins/translatePlus/misc/types"; -export function Icon({ width = 24, height = 24 }: IconProps) { +export function Icon() { return ( - + diff --git a/src/equicordplugins/unitConverter/ConverterAccessory.tsx b/src/equicordplugins/unitConverter/ConverterAccessory.tsx index 60d2980de..1ec77ada4 100644 --- a/src/equicordplugins/unitConverter/ConverterAccessory.tsx +++ b/src/equicordplugins/unitConverter/ConverterAccessory.tsx @@ -20,7 +20,7 @@ import { classNameFactory } from "@api/Styles"; import { Message } from "@vencord/discord-types"; import { useState } from "@webpack/common"; -export const conversions = new Map void>(); +export const conversions = new Map void>(); const cl = classNameFactory("vc-converter-"); function Dismiss({ onDismiss }: { onDismiss: () => void; }) { return ( @@ -33,17 +33,13 @@ function Dismiss({ onDismiss }: { onDismiss: () => void; }) { ); } // thanks <@408047304864432139> -export function ConvertIcon({ height = 24, width = 24, className }: { - height?: number, - width?: number, - className?: string; -}) { +export function ConvertIcon() { return ( ); } + +export function SmallConvertIcon() { + return ( + + + + ); +} + export function ConverterAccessory({ message }: { message: Message; }) { const [conversion, setConversion] = useState(""); conversions.set(message.id, setConversion); if (!conversion) return null; return ( - + {conversion} {" - "} setConversion("")} /> diff --git a/src/equicordplugins/unitConverter/index.tsx b/src/equicordplugins/unitConverter/index.tsx index 6da1864da..36d83568e 100644 --- a/src/equicordplugins/unitConverter/index.tsx +++ b/src/equicordplugins/unitConverter/index.tsx @@ -19,7 +19,6 @@ import "./style.css"; import { addMessageAccessory } from "@api/MessageAccessories"; -import { addMessagePopoverButton } from "@api/MessagePopover"; import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -50,9 +49,9 @@ export default definePlugin({ name: "UnitConverter", description: "Converts metric units to Imperal units and vice versa", authors: [Devs.sadan], - start() { - addMessageAccessory("vc-converter", props => ); - addMessagePopoverButton("vc-converter", message => { + messagePopoverButton: { + icon: ConvertIcon, + render(message) { if (!message.content) return null; return { label: "Convert Units", @@ -65,7 +64,10 @@ export default definePlugin({ setConversion(convert(message.content)); } }; - }); + } + }, + start() { + addMessageAccessory("vc-converter", props => ); }, settings, });