From a4fb30ebbf2d7cbace4201c99fa6b1e3e24ccfab Mon Sep 17 00:00:00 2001 From: OTKUSteyler Date: Tue, 16 Jun 2026 20:44:29 +0200 Subject: [PATCH] Update index.ts --- src/core/plugins/lovefemboys/index.ts | 303 +++++++++++++------------- 1 file changed, 153 insertions(+), 150 deletions(-) diff --git a/src/core/plugins/lovefemboys/index.ts b/src/core/plugins/lovefemboys/index.ts index 7f0b7f9..e47c424 100644 --- a/src/core/plugins/lovefemboys/index.ts +++ b/src/core/plugins/lovefemboys/index.ts @@ -1,15 +1,41 @@ import { defineCorePlugin } from ".."; -import { findByProps } from "@vendetta/metro"; -import { storage } from "@vendetta/plugin"; -import { alerts } from "@vendetta/ui"; + +const findByProps = (...props: string[]) => + (window as any).bunny?.metro?.findByProps(...props) ?? + (window as any).vendetta?.metro?.findByProps(...props); const MessageActions = findByProps("sendMessage", "receiveMessage"); const Channels = findByProps("getLastSelectedChannelId"); const BotMessage = findByProps("createBotMessage"); const Avatars = findByProps("BOT_AVATARS"); -function sendReply(channelID, content, embed) { - const channel = channelID ?? Channels?.getChannelId?.(); +// Simple in-memory storage since @vendetta/plugin isn't available in core +const storage: Record = { + sortdefs: "hot", + nsfwwarn: true, +}; + +function showConfirm(title: string, content: string): Promise { + return new Promise((resolve) => { + const UI = findByProps("showConfirmationAlert") ?? findByProps("openAlert"); + if (UI?.showConfirmationAlert) { + UI.showConfirmationAlert({ + title, + content, + confirmText: "Yes, Continue", + onConfirm: () => resolve(true), + cancelText: "Cancel", + onCancel: () => resolve(false), + }); + } else { + // fallback if alert API unavailable + resolve(confirm(`${title}\n\n${content}`)); + } + }); +} + +function sendReply(channelID: string, content: string | object, embed: any[]) { + const channel = channelID ?? Channels?.getLastSelectedChannelId?.(); const msg = BotMessage.createBotMessage({ channelId: channel, content: "", @@ -18,7 +44,7 @@ function sendReply(channelID, content, embed) { msg.author.username = "Astolfo"; msg.author.avatar = "Astolfo"; Avatars.BOT_AVATARS.Astolfo = - "https://i.pinimg.com/736x/50/77/1f/50771f45b1c015cfbb8b0853ba7b8521.jpg"; + "https://i.pinimg.com/736x/50/77/1f/50771f45b1c015cfbb8b0853ba7b8521.jpg"; if (typeof content === "string") { msg.content = content; } else { @@ -27,148 +53,125 @@ function sendReply(channelID, content, embed) { MessageActions.receiveMessage(channel, msg); } -export const lovefemboysCommand = { - name: "lovefemboys", - displayName: "lovefemboys", - description: "Get an image of a femboy", - displayDescription: "Get an image of a femboy", - options: [ - { - name: "nsfw", - displayName: "nsfw", - description: "Get the result from r/femboys instead of r/femboy (NSFW)", - displayDescription: - "Get the result from r/femboys instead of r/femboy (NSFW)", - required: false, - type: 5, - }, - { - name: "sort", - displayName: "sort", - description: "Changes the way reddit sorts.", - displayDescription: "Changes the way reddit sorts", - required: false, - type: 3, - }, - { - name: "silent", - displayName: "silent", - description: "Makes it so only you can see the message.", - displayDescription: "Makes it so only you can see the message.", - required: false, - type: 5, - }, - ], - applicationId: "-1", - inputType: 1, - type: 1, - execute: async (args, ctx) => { - try { - // Some code taken from enmity gotfemboys plugin by spinfal & was modified with the help of meqativ - const nsfw = args.find((arg) => arg.name === "nsfw")?.value; - let sort = args.find((arg) => arg.name === "sort")?.value; - const silent = args.find((arg) => arg.name === "silent")?.value; - - if (typeof sort === "undefined") sort = storage.sortdefs; - if ( - !["best", "hot", "new", "rising", "top", "controversial"].includes(sort) - ) { - sendReply( - ctx.channel.id, - "Incorrect sorting type. Valid options are\n`best`, `hot`, `new`, `rising`, `top`, `controversial`.", - [], - ); - return; - } - - // Show NSFW warning popup only when nsfw option is selected - if (nsfw) { - const shouldProceed = await new Promise((resolve) => { - alerts.showConfirmationAlert({ - title: "⚠️ NSFW Content Warning", - content: - "This command will send NSFW (Not Safe For Work) content from r/femboys. Are you sure you want to continue?", - confirmText: "Yes, Continue", - onConfirm: () => resolve(true), - cancelText: "Cancel", - onCancel: () => resolve(false), - }); - }); - - if (!shouldProceed) { - return null; - } - } - - let response = await fetch( - `https://www.reddit.com/r/femboy/${sort}.json?limit=100`, - ).then((res) => res.json()); - - if (!ctx.channel.nsfw_ && nsfw && storage.nsfwwarn && !(silent ?? true)) { - sendReply( - ctx.channel.id, - "This channel is not marked as NSFW\n(You can disable this check in plugin settings)", - [], - ); - return; - } - - if (nsfw) { - response = await fetch( - `https://www.reddit.com/r/femboys/${sort}.json?limit=100`, - ).then((res) => res.json()); - } - - response = - response.data?.children?.[ - Math.floor(Math.random() * response.data?.children?.length) - ]?.data; - const author = await fetch( - `https://www.reddit.com/u/${response?.author}/about.json`, - ).then((res) => res.json()); - - if (silent ?? true) { - sendReply(ctx.channel.id, "", [ - { - type: "rich", - title: response?.title, - url: `https://reddit.com${response?.permalink}`, - author: { - name: `u/${response?.author} • r/${response?.subreddit}`, - proxy_icon_url: author?.data.icon_img.split("?")[0], - icon_url: author?.data.icon_img.split("?")[0], - }, - image: { - proxy_url: - response?.url_overridden_by_dest?.replace(/.gifv$/g, ".gif") ?? - response?.url.replace(/.gifv$/g, ".gif"), - url: - response?.url_overridden_by_dest?.replace(/.gifv$/g, ".gif") ?? - response?.url?.replace(/.gifv$/g, ".gif"), - width: response?.preview?.images?.[0]?.source?.width, - height: response?.preview?.images?.[0]?.source?.height, - }, - color: "0xf4b8e4", - }, - ]); - } else { - const fixNonce = Date.now().toString(); - MessageActions.sendMessage( - ctx.channel.id, - { - content: response?.url_overridden_by_dest ?? response?.url, - }, - void 0, - { nonce: fixNonce }, - ); - } - } catch (err) { - console.error("[LoveFemboys] Error:", err); - sendReply( - ctx.channel.id, - "ERROR !!!!!!!!!!!! 😭😭😭 Check debug logs!! 🥺🥺🥺", - [], - ); - } +export default defineCorePlugin({ + manifest: { + id: "lovefemboys", + name: "LoveFemboys", + version: "1.0.0", + description: "Get an image of a femboy via slash command", + authors: [], }, -}; + onLoad() { + const { registerCommand } = findByProps("registerCommand"); + + this._unregister = registerCommand({ + name: "lovefemboys", + displayName: "lovefemboys", + description: "Get an image of a femboy", + displayDescription: "Get an image of a femboy", + applicationId: "-1", + inputType: 1, + type: 1, + options: [ + { + name: "nsfw", + displayName: "nsfw", + description: "Get the result from r/femboys instead of r/femboy (NSFW)", + displayDescription: "Get the result from r/femboys instead of r/femboy (NSFW)", + required: false, + type: 5, + }, + { + name: "sort", + displayName: "sort", + description: "Changes the way reddit sorts.", + displayDescription: "Changes the way reddit sorts", + required: false, + type: 3, + }, + { + name: "silent", + displayName: "silent", + description: "Makes it so only you can see the message.", + displayDescription: "Makes it so only you can see the message.", + required: false, + type: 5, + }, + ], + execute: async (args: any[], ctx: any) => { + try { + const nsfw = args.find((a) => a.name === "nsfw")?.value; + let sort = args.find((a) => a.name === "sort")?.value; + const silent = args.find((a) => a.name === "silent")?.value; + + if (typeof sort === "undefined") sort = storage.sortdefs; + if (!["best", "hot", "new", "rising", "top", "controversial"].includes(sort)) { + sendReply(ctx.channel.id, "Incorrect sorting type. Valid options are\n`best`, `hot`, `new`, `rising`, `top`, `controversial`.", []); + return; + } + + if (nsfw) { + const ok = await showConfirm( + "⚠️ NSFW Content Warning", + "This command will send NSFW content from r/femboys. Are you sure you want to continue?" + ); + if (!ok) return; + } + + let response = await fetch( + `https://www.reddit.com/r/femboy${nsfw ? "s" : ""}/${sort}.json?limit=100` + ).then((r) => r.json()); + + if (!ctx.channel.nsfw_ && nsfw && storage.nsfwwarn && !(silent ?? true)) { + sendReply(ctx.channel.id, "This channel is not marked as NSFW.", []); + return; + } + + response = response.data?.children?.[ + Math.floor(Math.random() * response.data?.children?.length) + ]?.data; + + const author = await fetch( + `https://www.reddit.com/u/${response?.author}/about.json` + ).then((r) => r.json()); + + if (silent ?? true) { + sendReply(ctx.channel.id, "", [ + { + type: "rich", + title: response?.title, + url: `https://reddit.com${response?.permalink}`, + author: { + name: `u/${response?.author} • r/${response?.subreddit}`, + proxy_icon_url: author?.data.icon_img.split("?")[0], + icon_url: author?.data.icon_img.split("?")[0], + }, + image: { + proxy_url: response?.url_overridden_by_dest?.replace(/.gifv$/g, ".gif") ?? response?.url?.replace(/.gifv$/g, ".gif"), + url: response?.url_overridden_by_dest?.replace(/.gifv$/g, ".gif") ?? response?.url?.replace(/.gifv$/g, ".gif"), + width: response?.preview?.images?.[0]?.source?.width, + height: response?.preview?.images?.[0]?.source?.height, + }, + color: "0xf4b8e4", + }, + ]); + } else { + const fixNonce = Date.now().toString(); + MessageActions.sendMessage( + ctx.channel.id, + { content: response?.url_overridden_by_dest ?? response?.url }, + void 0, + { nonce: fixNonce } + ); + } + } catch (err) { + console.error("[LoveFemboys] Error:", err); + sendReply(ctx.channel.id, "ERROR !!!!!!!!!!!! 😭😭😭 Check debug logs!! 🥺🥺🥺", []); + } + }, + }); + }, + onUnload() { + this._unregister?.(); + }, +});