diff options
author | 12944qwerty <qwerty12944qwerty@gmail.com> | 2022-12-02 09:38:52 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 16:38:52 +0100 |
commit | 4760af7f0ee275caa1eee440f4945032057d2b56 (patch) | |
tree | 7da3e052dd96ecb4988ba22f964f3ff5b8f97b51 /src/utils | |
parent | 06d32ae414bbd160d355fe62c643a20976193d49 (diff) | |
download | Vencord-4760af7f0ee275caa1eee440f4945032057d2b56.tar.gz Vencord-4760af7f0ee275caa1eee440f4945032057d2b56.tar.bz2 Vencord-4760af7f0ee275caa1eee440f4945032057d2b56.zip |
add ViewRaw plugin & MiniPopover API (#275)
Co-authored-by: Vendicated <vendicated@riseup.net>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/constants.ts | 4 | ||||
-rw-r--r-- | src/utils/misc.tsx | 24 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 3766c74..eead2a3 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -156,5 +156,9 @@ export const Devs = Object.freeze({ Luna: { name: "Luny", id: 821472922140803112n + }, + KingFish: { + name: "King Fish", + id: 499400512559382538n } }); diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 4ae3fd5..d9164a0 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { React } from "@webpack/common"; +import { Clipboard, React, Toasts } from "@webpack/common"; /** * Makes a lazy function. On first call, the value is computed. @@ -175,5 +175,25 @@ export function suppressErrors<F extends Function>(name: string, func: F, thisOb */ export function makeCodeblock(text: string, language?: string) { const chars = "```"; - return `${chars}${language || ""}\n${text}\n${chars}`; + return `${chars}${language || ""}\n${text.replaceAll("```", "\\`\\`\\`")}\n${chars}`; +} + +export function copyWithToast(text: string, toastMessage = "Copied to clipboard!") { + if (Clipboard.SUPPORTS_COPY) { + Clipboard.copy(text); + } else { + toastMessage = "Your browser does not support copying to clipboard"; + } + Toasts.show({ + message: toastMessage, + id: Toasts.genId(), + type: Toasts.Type.SUCCESS + }); +} + +/** + * Check if obj is a true object: of type "object" and not null or array + */ +export function isObject(obj: unknown): obj is object { + return typeof obj === "object" && obj !== null && !Array.isArray(obj); } |