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