From 4d3eabc9f277a06e9922768962ecf96983c52549 Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Sun, 9 Jul 2023 08:30:26 +0800 Subject: [PATCH] Ditch unneccesary classes in plugin entries --- plugins/HideGiftButton/src/index.ts | 15 +++++++-------- plugins/NoAutoReplyMention/src/index.ts | 19 ++++++++----------- plugins/NoIdle/src/index.ts | 22 +++++----------------- plugins/defs.d.ts | 10 +++++----- 4 files changed, 25 insertions(+), 41 deletions(-) diff --git a/plugins/HideGiftButton/src/index.ts b/plugins/HideGiftButton/src/index.ts index 6f304f2..63c9625 100644 --- a/plugins/HideGiftButton/src/index.ts +++ b/plugins/HideGiftButton/src/index.ts @@ -1,17 +1,16 @@ -import { logger } from "@vendetta"; import { findByName } from "@vendetta/metro"; const ChatInput = findByName("ChatInput"); -export default new class HideGiftButton { - origState: boolean; +// Object.defineProperty(ChatInput.defaultProps, "hideGiftButton", { +// get: () => plugins?.[plugin.id]?.enabled +// }); + +export default { onLoad() { - logger.log("Starting HideGiftButton..."); - this.origState = ChatInput.defaultProps.hideGiftButton; ChatInput.defaultProps.hideGiftButton = true; - } + }, onUnload() { - logger.log("Unloading HideGiftButton.."); - ChatInput.defaultProps.hideGiftButton = this.origState; + ChatInput.defaultProps.hideGiftButton = false; } }; diff --git a/plugins/NoAutoReplyMention/src/index.ts b/plugins/NoAutoReplyMention/src/index.ts index 25cf330..f8607c4 100644 --- a/plugins/NoAutoReplyMention/src/index.ts +++ b/plugins/NoAutoReplyMention/src/index.ts @@ -10,18 +10,15 @@ export interface SettingsSchema { exempted: string[]; } -export const settings = storage as SettingsSchema; +storage.isBlacklistMode ??= false; +storage.exempted ??= []; const ReplyManager = findByProps("createPendingReply"); -settings.isBlacklistMode ??= false; -settings.exempted ??= []; - -export default new class NoAutoReplyMention { - settings = Settings; - - onUnload = patcher.before("createPendingReply", ReplyManager, ([arg]) => { - const isListed = settings.exempted.includes(arg.message?.author?.id); - arg.shouldMention &&= settings.isBlacklistMode ? !isListed : isListed; - }); +export default { + settings: Settings, + onUnload: patcher.before("createPendingReply", ReplyManager, ([arg]) => { + const isListed = storage.exempted.includes(arg.message?.author?.id); + arg.shouldMention &&= storage.isBlacklistMode ? !isListed : isListed; + }) }; diff --git a/plugins/NoIdle/src/index.ts b/plugins/NoIdle/src/index.ts index e60f2e0..3609dc1 100644 --- a/plugins/NoIdle/src/index.ts +++ b/plugins/NoIdle/src/index.ts @@ -1,20 +1,8 @@ -import { logger, patcher } from "@vendetta"; +import { patcher } from "@vendetta"; import { FluxDispatcher } from "@vendetta/metro/common"; -let unpatch: () => void; +export const onUnload = patcher.before("dispatch", FluxDispatcher, ([{ type }]) => { + if (type !== "IDLE") return; -export default new class NoIdle { - onLoad() { - logger.log("Starting NoIdle..."); - - unpatch = patcher.before("dispatch", FluxDispatcher, ([{ type }]) => { - if (type !== "IDLE") return; - - return [{ type: "IDLE", idle: false }]; - }); - } - onUnload() { - logger.log("Disabling NoIdle.."); - unpatch?.(); - } -}; + return [{ type: "IDLE", idle: false }]; +}); diff --git a/plugins/defs.d.ts b/plugins/defs.d.ts index 84285b3..1e93627 100644 --- a/plugins/defs.d.ts +++ b/plugins/defs.d.ts @@ -1,4 +1,4 @@ -type Activity = { +export type Activity = { name: string; application_id: string; flags: number; @@ -14,19 +14,19 @@ type Activity = { buttons: ActivityButton[]; }; -type ActivityButton = { +export type ActivityButton = { label: string; url: string; }; -type ActivityAssets = { +export type ActivityAssets = { large_image?: string; large_text?: string; small_image?: string; small_text?: string; }; -type LFMSettings = { +export type LFMSettings = { appName: string; username: string; showTimestamp: boolean; @@ -36,7 +36,7 @@ type LFMSettings = { verboseLogging: boolean; }; -type Track = { +export type Track = { name: string; artist: string; album: string;