4 lines
11 KiB
JavaScript
4 lines
11 KiB
JavaScript
(function(v,d,r,h,le,R,g,y,i,$,o){"use strict";const O=h.findByProps("sendMessage"),l=async function(e,t,a,n){if(!t)return{type:4};const s={content:t,...a&&n?.factSettings?.sendAsReply?{messageReference:{messageId:a}}:{}};return await O.sendMessage(e,s,void 0,{nonce:(Date.now()*4194304).toString()}),{type:4}},W=async function(){const e=await(await fetch("https://uselessfacts.jsph.pl/api/v2/facts/random")).json();return{text:e.text,source:e.source,language:e.language}},G=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},U=async function(){const e=await(await fetch("https://catfact.ninja/fact")).json();return{text:e.fact,length:e.length}},K=async function(e){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${e.replace("webp","png")}`)).json()},T=function(e){let t=e.text;return r.storage.factSettings?.includeCitation&&e.source&&(t+=`
|
|
|
|
Source: ${e.source}`),t},V={name:"catfact",displayName:"catfact",description:"Sends a random cat fact.",displayDescription:"Sends a random cat fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,t){const a=await U();return l(t.channel.id,T(a),t.message?.id,r.storage)}},q={name:"dogfact",displayName:"dogfact",description:"Sends a dog fact.",displayDescription:"Sends a dog fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,t){const a=await G();return l(t.channel.id,T(a),t.message?.id,r.storage)}},z={name:"useless",displayName:"useless",description:"Sends a useless fact.",displayDescription:"Sends a useless fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,t){const a=await W();return l(t.channel.id,T(a),t.message?.id,r.storage)}},b="https://vd-plugins.github.io/proxy/actuallythesun.github.io/vendetta-plugins/SplitLargeMessages/",u={ENABLED:"\u{1F7E2}",DISABLED:"\u{1F534}",SELECTED:"\u{1F536}",NOT_SELECTED:"\u{1F537}"},S=function(e){return e.map(function(t){return t.name}).join(", ")},f=function(e){return e.join(`
|
|
`).trimEnd()},x=function(e){return f(e).length},B=function(){return Object.keys(g.plugins).includes(b)},F=function(){return Object.values(g.plugins).find(function(e){return e.id===b})?.enabled??!1},_=function(){return y.alerts.showConfirmationAlert({title:"Large Message Warning",content:"This list is too long to send! Would you like to install the Split Large Messages plugin?",confirmText:"Install Plugin",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){i.openURL(b)}})},P=function(){return y.alerts.showConfirmationAlert({title:"Plugin Disabled",content:"The Split Large Messages plugin is installed but disabled. Would you like to enable it now?",confirmText:"Enable Plugin",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){const e=Object.values(g.plugins).find(function(t){return t.id===b});e&&(e.enabled=!0)}})};async function H(e,t){const a=r.storage.listSettings?.pluginListAlwaysDetailed??!1,n=[`**My Plugin List | ${Object.keys(g.plugins).length} Plugins**`,""];for(const s of Object.values(g.plugins)){const{enabled:C,manifest:D,id:I}=s,{name:L,description:A,authors:E}=D;e||a?n.push(`> **Name**: ${L}`,`> **Status**: ${C?u.ENABLED:u.DISABLED}`,`> **Description**: ${A}`,`> **Authors**: ${S(E)}`,`> **[Install!](${I})**`,""):n.push(`> ${C?u.ENABLED:u.DISABLED} **${L}** by ${S(E)}`)}return x(n)>2e3?B()?F()?y.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return l(t.channel.id,f(n))}}):P():_():l(t.channel.id,f(n))}async function J(e,t){const a=r.storage.themeListAlwaysDetailed??!1,n=[`**My Theme List | ${Object.keys(R.themes).length} Themes**`,""],s=Object.values(R.themes);if(s.length)for(const C of s){const{selected:D,data:I,id:L}=C,{name:A,description:E,authors:M}=I;e||a?n.push(`> **Name**: ${A}`,`> **Selected**: ${D?u.SELECTED:u.NOT_SELECTED}`,`> **Description**: ${E}`,`> **Authors**: ${S(M)}`,`> **[Install!](${L})**`,""):n.push(`> ${D?u.SELECTED:u.NOT_SELECTED} **${A}** by ${S(M)}`)}else n.push("Nothing to see here, huh...");return x(n)>2e3?B()?F()?y.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return l(t.channel.id,f(n))}}):P():_():l(t.channel.id,f(n))}const Q={name:"plugin-list",displayName:"plugin list",description:"Send your plugin list to the current channel",displayDescription:"Send your plugin list to the current channel",options:[{name:"detailed",description:"Whether to send a list with detailed information.",type:5,required:!1,displayName:"detailed",displayDescription:"Whether to send a list with detailed information."}],execute:async function(e,t){const a=e.find(function(n){return n.name==="detailed"})?.value??!1;return H(a,t)},applicationId:"-1",inputType:1,type:1},X={name:"theme-list",displayName:"theme list",description:"Send your theme list to the current channel",displayDescription:"Send your theme list to the current channel",options:[{name:"detailed",description:"Whether to send a list with detailed information.",type:5,required:!1,displayName:"detailed",displayDescription:"Whether to send a list with detailed information."}],execute:async function(e,t){const a=e.find(function(n){return n.name==="detailed"})?.value??!1;return J(a,t)},applicationId:"-1",inputType:1,type:1},Y=h.findByStoreName("UserStore"),Z={name:"petpet",displayName:"petpet",description:"PetPet someone",displayDescription:"PetPet someone",options:[{name:"user",description:"The user(or their id) to be patted",type:6,required:!0,displayName:"user",displayDescription:"The user(or their id) to be patted"}],execute:async function(e,t){const a=(await Y.getUser(e[0].value)).getAvatarURL(512),n=await K(a);return l(t.channel.id,n.url,t.message?.id)},applicationId:"-1",inputType:1,type:1},j=async function(e){const t="https://konachan.com/post.json",a=e?"rating:explicit":"rating:safe",n=Math.floor(Math.random()*100);try{const s=await(await fetch(`${t}?tags=${a}&limit=1&page=${n}`)).json();return!Array.isArray(s)||s.length===0?null:s[0].file_url}catch(s){return console.error("[KonoChan Randomizer] Error fetching image:",s),null}},k={name:"nsfw",description:"Include NSFW content?",type:5,required:!1,displayName:"nsfw",displayDescription:"Include NSFW content?"},ee={name:"konoself",displayName:"konoself",description:"Fetch a random image from KonoChan for yourself.",displayDescription:"Fetch a random image from KonoChan for yourself.",options:[k],execute:async function(e,t){const a=new Map(e.map(function(s){return[s.name,s]})).get("nsfw")?.value||!1,n=await j(a);return n?l(t.channel.id,`Here's your random image: ${n}`):l(t.channel.id,"No image found. Try again later.")},applicationId:"-1",inputType:1,type:1},te={name:"konosend",displayName:"konosend",description:"Fetch a random image from KonoChan and send it to the channel.",displayDescription:"Fetch a random image from KonoChan and send it to the channel.",options:[k],execute:async function(e,t){const a=new Map(e.map(function(s){return[s.name,s]})).get("nsfw")?.value||!1;if(a&&!t.channel.nsfw)return l(t.channel.id,"This channel is not marked as NSFW. Use an NSFW channel instead.");const n=await j(a);return n?l(t.channel.id,n):l(t.channel.id,"No image found. Try again later.")},applicationId:"-1",inputType:1,type:1},{ScrollView:ne}=h.findByProps("ScrollView"),{TableRowGroup:m,TableSwitchRow:c,Stack:ae}=h.findByProps("TableSwitchRow","TableRowGroup","Stack"),p=function(e,t=""){return $.plugin.storage[e]??t},w=function(e,t){return $.plugin.storage[e]=t};function ie(){const[e,t]=i.React.useReducer(function(n){return~n},0),a=function(){return t()};return i.React.createElement(ne,{style:{flex:1},contentContainerStyle:{padding:10}},i.React.createElement(ae,{spacing:8},i.React.createElement(m,{title:"Facts Settings"},i.React.createElement(c,{label:"Send as Reply",subLabel:"Send facts as a reply to the command message",icon:o.getAssetIDByName("ic_reply_24px"),value:p("factSettings.sendAsReply",!0),onValueChange:function(n){w("factSettings",{...p("factSettings",{}),sendAsReply:n}),a()}}),i.React.createElement(c,{label:"Include Source Citation",subLabel:"Include the source of facts when available",icon:o.getAssetIDByName("ic_info"),value:p("factSettings.includeCitation",!1),onValueChange:function(n){w("factSettings",{...p("factSettings",{}),includeCitation:n}),a()}})),i.React.createElement(m,{title:"Plugin List Settings"},i.React.createElement(c,{label:"Always Send Detailed List",subLabel:"Always use detailed mode when listing plugins",icon:o.getAssetIDByName("ic_message_copy"),value:p("listSettings.pluginListAlwaysDetailed",!1),onValueChange:function(n){w("listSettings",{...p("listSettings",{}),pluginListAlwaysDetailed:n}),a()}})),i.React.createElement(m,{title:"Theme List Settings"},i.React.createElement(c,{label:"Always Send Detailed List",subLabel:"Always use detailed mode when listing themes",icon:o.getAssetIDByName("ic_theme"),value:p("listSettings.themeListAlwaysDetailed",!1),onValueChange:function(n){w("listSettings",{...p("listSettings",{}),themeListAlwaysDetailed:n}),a()}})),i.React.createElement(m,{title:"Available Commands"},i.React.createElement(c,{label:"/catfact",subLabel:"Get random cat facts",icon:o.getAssetIDByName("ic_info"),value:!0,disabled:!0}),i.React.createElement(c,{label:"/dogfact",subLabel:"Get random dog facts",icon:o.getAssetIDByName("ic_info"),value:!0,disabled:!0}),i.React.createElement(c,{label:"/useless",subLabel:"Get random useless facts",icon:o.getAssetIDByName("ic_info"),value:!0,disabled:!0}),i.React.createElement(c,{label:"/petpet",subLabel:"Create pet-pet GIF of a user",icon:o.getAssetIDByName("ic_image"),value:!0,disabled:!0}),i.React.createElement(c,{label:"/plugin-list",subLabel:"List all installed plugins",icon:o.getAssetIDByName("ic_plugins"),value:!0,disabled:!0}),i.React.createElement(c,{label:"/theme-list",subLabel:"List all installed themes",icon:o.getAssetIDByName("ic_theme"),value:!0,disabled:!0}),i.React.createElement(c,{label:"/konoself, /konosend",subLabel:"Get random images from KonoChan",icon:o.getAssetIDByName("ic_image"),value:!0,disabled:!0})),i.React.createElement(m,{title:"About"},i.React.createElement(c,{label:"All-In-One Commands",subLabel:"A collection of useful commands",icon:o.getAssetIDByName("ic_badge_staff"),value:!0,disabled:!0}))))}r.storage.factSettings||(r.storage.factSettings={sendAsReply:!0,includeCitation:!1}),r.storage.listSettings||(r.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1});let N=[];var se={onLoad:function(){console.log("[All-In-One Commands] Loading plugin..."),N=[d.registerCommand(V),d.registerCommand(q),d.registerCommand(z),d.registerCommand(Z),d.registerCommand(Q),d.registerCommand(X),d.registerCommand(ee),d.registerCommand(te)],console.log("[All-In-One Commands] Plugin loaded successfully!")},onUnload:function(){console.log("[All-In-One Commands] Unloading plugin..."),N.forEach(function(e){return e()}),N=[],console.log("[All-In-One Commands] Plugin unloaded successfully!")},settings:ie};return v.default=se,Object.defineProperty(v,"__esModule",{value:!0}),v})({},vendetta.commands,vendetta.plugin,vendetta.metro,vendetta.ui.toasts,vendetta.themes,vendetta.plugins,vendetta.ui,vendetta.metro.common,vendetta,vendetta.ui.assets);
|