diff --git a/src/Settings.tsx b/src/Settings.tsx index 0ba4558..78bad9f 100644 --- a/src/Settings.tsx +++ b/src/Settings.tsx @@ -51,6 +51,9 @@ export function Settings() { Spoof stream quality (Use at your own risk! May lead to account ban) + + Enable verbose logging in console + ); diff --git a/src/index.ts b/src/index.ts index c6bdc29..d698131 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { Injector } from "replugged"; -import { config, ready, userChanged, userInit } from "./misc"; +import { config, logger, ready, userChanged, userInit } from "./misc"; import { addStickerPreview, @@ -21,6 +21,12 @@ import { spoofSticker } from "./sticker"; const injector = new Injector(); export async function start(): Promise { + if (config.get("debugMode")) { + logger.log("stickerInfo:", stickerInfo); + logger.log("stickerSendability:", stickerSendability); + logger.log("stickerPreview:", stickerPreview); + } + // using premiumType from common.users.getCurrentUser will broke with plugins like No Nitro Upsell await userInit(); @@ -44,8 +50,17 @@ export async function start(): Promise { injector.instead(stickerSendability, isSendableSticker, () => true); injector.instead(stickerPreview, addStickerPreview, async ([channelId, sticker, d], orig) => { + const debugMode = config.get("debugMode"); + if (debugMode) { + logger.log("ready:", ready); + } + if (ready) { const spoofed = await spoofSticker(sticker); + if (debugMode) { + logger.log("orig:", orig); + } + if (!spoofed) { orig(channelId, sticker, d); } diff --git a/src/misc.ts b/src/misc.ts index 415c43d..d6f7a1b 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -1,4 +1,4 @@ -import { common, settings } from "replugged"; +import { Logger, common, settings } from "replugged"; import { userProfileFetch } from "./webpack"; import { User } from "discord-types/general"; @@ -11,8 +11,12 @@ export const config = await settings.init("com.cafeed28.NitroSpoof", { stickerSize: 160, streamQualityEnable: false, + + debugMode: false, }); +export const logger = Logger.plugin("NitroSpoof"); + export const HIDE_TEXT_SPOILERS = "||\u200b||".repeat(199); export let userPremiumType: PremiumType; diff --git a/src/sticker.ts b/src/sticker.ts index d2c2f16..d9129b4 100644 --- a/src/sticker.ts +++ b/src/sticker.ts @@ -1,5 +1,5 @@ import { common } from "replugged"; -import { userPremiumType } from "./misc"; +import { config, logger, userPremiumType } from "./misc"; import { PremiumType, Sticker, StickerFormat, StickerType } from "./types"; import { files } from "./webpack"; import { renderPng } from "./renderer"; @@ -21,6 +21,12 @@ function getUrl(sticker: Sticker): string { } function isStickerAvailable(sticker: Sticker): boolean { + if (config.get("debugMode")) { + logger.log("sticker:", sticker); + logger.log("userPremiumType:", userPremiumType); + logger.log("common.guilds.getGuildId:", common.guilds.getGuildId()); + } + if (sticker.type == StickerType.STANDARD) return true; // Emoji not available on Discord (e.g. GUILD_SUBSCRIPTION_UNAVAILABLE) diff --git a/src/types.ts b/src/types.ts index efde0c8..9d3528f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,6 +6,8 @@ export type Config = { stickerSize?: number; streamQualityEnable?: boolean; + + debugMode?: boolean; }; export enum PremiumType {