4 lines
16 KiB
JavaScript
4 lines
16 KiB
JavaScript
(function(v,q,s,g,M,S,C,i,K,G){"use strict";const U=g.findByProps("sendMessage"),p=function(n,t,a,e,o){if(!t)return{type:4};if(o)return{type:4,data:{content:t,flags:64}};const l={content:t,...a&&e?.factSettings?.sendAsReply?{messageReference:{messageId:a}}:{}};return U.sendMessage(n,l,void 0,{nonce:(Date.now()*4194304).toString()}),{type:4}},z=async function(){const n=await(await fetch("https://uselessfacts.jsph.pl/api/v2/facts/random")).json();return{text:n.text,source:n.source,language:n.language}},H=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},Y=async function(){const n=await(await fetch("https://catfact.ninja/fact")).json();return{text:n.fact,length:n.length}},J=async function(n){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${n.replace("webp","png")}`)).json()},D=function(n){let t=n.text;return s.storage.factSettings?.includeCitation&&n.source&&(t+=`
|
|
|
|
Source: ${n.source}`),t},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(n,t){const a=await Y();return p(t.channel.id,D(a),t.message?.id,s.storage)}},X={name:"dogfact",displayName:"dogfact",description:"Sends a dog fact.",displayDescription:"Sends a dog fact.",applicationId:"-1",inputType:1,type:1,execute:async function(n,t){const a=await H();return p(t.channel.id,D(a),t.message?.id,s.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(n,t){const a=await z();return p(t.channel.id,D(a),t.message?.id,s.storage)}},E="https://vd-plugins.github.io/proxy/actuallythesun.github.io/vendetta-plugins/SplitLargeMessages/",h={ENABLED:"\u{1F7E2}",DISABLED:"\u{1F534}",SELECTED:"\u{1F536}",NOT_SELECTED:"\u{1F537}"},$=function(n){return n.map(function(t){return t.name}).join(", ")},L=function(n){return n.join(`
|
|
`).trimEnd()},N=function(n){return L(n).length},x=function(){return Object.keys(S.plugins).includes(E)},P=function(){return Object.values(S.plugins).find(function(n){return n.id===E})?.enabled??!1},k=function(){return C.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(E)}})},I=function(){return C.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 n=Object.values(S.plugins).find(function(t){return t.id===E});n&&(n.enabled=!0)}})};async function ee(n,t){const a=s.storage.listSettings?.pluginListAlwaysDetailed??!1,e=[`**My Plugin List | ${Object.keys(S.plugins).length} Plugins**`,""];for(const o of Object.values(S.plugins)){const{enabled:l,manifest:d,id:f}=o,{name:m,description:u,authors:r}=d;n||a?e.push(`> **Name**: ${m}`,`> **Status**: ${l?h.ENABLED:h.DISABLED}`,`> **Description**: ${u}`,`> **Authors**: ${$(r)}`,`> **[Install!](${f})**`,""):e.push(`> ${l?h.ENABLED:h.DISABLED} **${m}** by ${$(r)}`)}return N(e)>2e3?x()?P()?C.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return p(t.channel.id,L(e))}}):I():k():p(t.channel.id,L(e))}async function te(n,t){const a=s.storage.themeListAlwaysDetailed??!1,e=[`**My Theme List | ${Object.keys(M.themes).length} Themes**`,""],o=Object.values(M.themes);if(o.length)for(const l of o){const{selected:d,data:f,id:m}=l,{name:u,description:r,authors:b}=f;n||a?e.push(`> **Name**: ${u}`,`> **Selected**: ${d?h.SELECTED:h.NOT_SELECTED}`,`> **Description**: ${r}`,`> **Authors**: ${$(b)}`,`> **[Install!](${m})**`,""):e.push(`> ${d?h.SELECTED:h.NOT_SELECTED} **${u}** by ${$(b)}`)}else e.push("Nothing to see here, huh...");return N(e)>2e3?x()?P()?C.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return p(t.channel.id,L(e))}}):I():k():p(t.channel.id,L(e))}const ne={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(n,t){const a=n.find(function(e){return e.name==="detailed"})?.value??!1;return ee(a,t)},applicationId:"-1",inputType:1,type:1},ae={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(n,t){const a=n.find(function(e){return e.name==="detailed"})?.value??!1;return te(a,t)},applicationId:"-1",inputType:1,type:1},se=g.findByStoreName("UserStore"),ie={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(n,t){const a=(await se.getUser(n[0].value)).getAvatarURL(512),e=await J(a);return p(t.channel.id,e.url,t.message?.id)},applicationId:"-1",inputType:1,type:1},F=g.findByProps("sendMessage"),B=g.findByProps("sendBotMessage","sendMessage","receiveMessage"),j=async function(n){const t="https://konachan.com/post.json",a=n?"rating:explicit":"rating:safe",e=Math.floor(Math.random()*100);try{const o=await(await fetch(`${t}?tags=${a}&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}},O=function(){return C.alerts.showConfirmationAlert({title:"NSFW Content Warning",content:"NSFW content can only be sent in NSFW channels!",confirmText:"Okay",cancelText:null,confirmColor:"brand",isDismissable:!0})},_={name:"nsfw",description:"Include NSFW content?",type:5,required:!1,displayName:"nsfw",displayDescription:"Include NSFW content?"},oe={name:"konoself",displayName:"konoself",description:"Fetch a random image from KonoChan for yourself.",displayDescription:"Fetch a random image from KonoChan for yourself.",options:[_],execute:async function(n,t){const a=new Map(n.map(function(o){return[o.name,o]})).get("nsfw")?.value||!1;if(a&&!t.channel.nsfw)return O(),{type:4};const e=await j(a);return e?(B.sendBotMessage(t.channel.id,`Here's your random image: ${e}`),{type:4}):(B.sendBotMessage(t.channel.id,"No image found. Try again later."),{type:4})},applicationId:"-1",inputType:1,type:1},re={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:[_],execute:async function(n,t){const a=new Map(n.map(function(l){return[l.name,l]})).get("nsfw")?.value||!1;if(a&&!t.channel.nsfw)return O(),{type:4};const e=await j(a);if(!e){const l=Date.now().toString();return F.sendMessage(t.channel.id,{content:"No image found. Try again later."},void 0,{nonce:l}),{type:4}}const o=Date.now().toString();return F.sendMessage(t.channel.id,{content:e},void 0,{nonce:o}),{type:4}},applicationId:"-1",inputType:1,type:1},V=g.findByProps("getAPIBaseURL","get"),le=g.findByProps("sendMessage"),T=g.findByProps("sendBotMessage","sendMessage","receiveMessage"),R=async function(n,t,a){const e=t?`&author_id=${t}`:"",o=a?`&channel_id=${a}`:"",l=t?"":"&min_id=0";return(await V.get({url:`/guilds/${n}/messages/search`,query:`include_nsfw=true${e}${o}${l}&sort_by=timestamp&sort_order=asc&offset=0`})).body.messages[0][0]},W=async function(n,t){const a=t?`&author_id=${t}`:"",e=t?"":"&min_id=0";return(await V.get({url:`/channels/${n}/messages/search`,query:`&sort_by=timestamp&sort_order=asc&offset=0${a}${e}`})).body.messages[0][0]},ce={name:"firstmessage",displayName:"firstmessage",description:"Tired of scrolling to first message?",displayDescription:"Tired of scrolling to first message?",options:[{name:"user",displayName:"user",description:"Target user to get their first message in this server/dm",displayDescription:"Target user to get their first message in this server/dm",type:6,required:!1},{name:"channel",displayName:"channel",description:"Target channel to get first message of",displayDescription:"Target channel to get first message of",type:7,required:!1},{name:"send",displayName:"send",description:"Whether to send the resulting url",displayDescription:"Whether to send the resulting url",type:5,required:!1}],execute:async function(n,t){try{const a=new Map(n.map(function(b){return[b.name,b]})),e=a.get("user")?.value,o=a.get("channel")?.value,l=a.get("send")?.value,d=t.guild?.id,f=t.channel.id,m=t.channel.type===1;let u="https://discord.com/channels/",r;if(!e&&!o)m?(r=await W(f),u+=`@me/${f}/${r.id}`):(r=await R(d),u+=`${d}/${r.channel_id}/${r.id}`);else if(e)m?(r=await W(f,e),u+=`@me/${f}/${r.id}`):(r=await R(d,e),u+=`${d}/${r.channel_id}/${r.id}`);else if(o){if(m)return T.sendBotMessage(f,"This combination cannot be used in DMs!"),{type:4};r=await R(d,null,o),u+=`${d}/${o}/${r.id}`}else{if(m)return T.sendBotMessage(f,"This combination cannot be used in DMs!"),{type:4};r=await R(d,e,o),u+=`${d}/${o}/${r.id}`}if(l){const b=Date.now().toString();return le.sendMessage(t.channel.id,{content:u},void 0,{nonce:b}),{type:4}}else return i.url.openDeeplink(u),{type:4}}catch(a){return console.error("[FirstMessage] Error:",a),T.sendBotMessage(t.channel.id,"Failed to fetch the first message. Please try again."),{type:4}}},applicationId:"-1",inputType:1,type:1},{ScrollView:de}=g.findByProps("ScrollView"),{TableRowGroup:y,TableSwitchRow:c,Stack:ue,TableRow:w}=g.findByProps("TableSwitchRow","TableRowGroup","Stack","TableRow");s.storage.factSettings||(s.storage.factSettings={sendAsReply:!0,includeCitation:!1}),s.storage.listSettings||(s.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),s.storage.enabledCommands||(s.storage.enabledCommands={catfact:!0,dogfact:!0,useless:!0,petpet:!0,pluginList:!0,themeList:!0,konoself:!0,konosend:!0,firstmessage:!0}),s.storage.pendingRestart||(s.storage.pendingRestart=!1);function fe(){K.useProxy(s.storage);const[n,t]=i.React.useReducer(function(e){return e+1},0);i.React.useEffect(function(){return function(){s.storage.pendingRestart&&(s.storage.pendingRestart=!1,C.alerts.showConfirmationAlert({title:"Restart Required",content:"You have made changes to commands. Please restart Discord to apply these changes.",confirmText:"Okay",cancelText:null}))}},[]);const a=function(e,o){s.storage.enabledCommands[e]=o,s.storage.pendingRestart=!0,t()};return i.React.createElement(G.View,{style:{flex:1}},i.React.createElement(de,{style:{flex:1},contentContainerStyle:{paddingBottom:38}},i.React.createElement(ue,{spacing:8},i.React.createElement(y,{title:"Facts Commands"},i.React.createElement(c,{label:"Send as Reply",subLabel:"Send facts as a reply to the command message",value:s.storage.factSettings?.sendAsReply??!0,onValueChange:function(e){s.storage.factSettings.sendAsReply=e,t()}}),i.React.createElement(c,{label:"Include Source Citation",subLabel:"Include the source of facts when available",value:s.storage.factSettings?.includeCitation??!1,onValueChange:function(e){s.storage.factSettings.includeCitation=e,t()}}),i.React.createElement(c,{label:"/catfact",subLabel:"Get random cat facts",value:s.storage.enabledCommands?.catfact??!0,onValueChange:function(e){return a("catfact",e)}}),i.React.createElement(c,{label:"/dogfact",subLabel:"Get random dog facts",value:s.storage.enabledCommands?.dogfact??!0,onValueChange:function(e){return a("dogfact",e)}}),i.React.createElement(c,{label:"/useless",subLabel:"Get random useless facts",value:s.storage.enabledCommands?.useless??!0,onValueChange:function(e){return a("useless",e)}})),i.React.createElement(y,{title:"List Commands"},i.React.createElement(c,{label:"Always Send Detailed Plugin List",subLabel:"Always use detailed mode when listing plugins",value:s.storage.listSettings?.pluginListAlwaysDetailed??!1,onValueChange:function(e){s.storage.listSettings.pluginListAlwaysDetailed=e,t()}}),i.React.createElement(c,{label:"Always Send Detailed Theme List",subLabel:"Always use detailed mode when listing themes",value:s.storage.listSettings?.themeListAlwaysDetailed??!1,onValueChange:function(e){s.storage.listSettings.themeListAlwaysDetailed=e,t()}}),i.React.createElement(c,{label:"/plugin-list",subLabel:"List all installed plugins",value:s.storage.enabledCommands?.pluginList??!0,onValueChange:function(e){return a("pluginList",e)}}),i.React.createElement(c,{label:"/theme-list",subLabel:"List all installed themes",value:s.storage.enabledCommands?.themeList??!0,onValueChange:function(e){return a("themeList",e)}})),i.React.createElement(y,{title:"Image Commands"},i.React.createElement(c,{label:"/petpet",subLabel:"Create pet-pet GIF of a user",value:s.storage.enabledCommands?.petpet??!0,onValueChange:function(e){return a("petpet",e)}})),i.React.createElement(y,{title:"KonoChan Commands"},i.React.createElement(c,{label:"/konoself",subLabel:"Get random image from KonoChan (private)",value:s.storage.enabledCommands?.konoself??!0,onValueChange:function(e){return a("konoself",e)}}),i.React.createElement(c,{label:"/konosend",subLabel:"Send random image from KonoChan to channel",value:s.storage.enabledCommands?.konosend??!0,onValueChange:function(e){return a("konosend",e)}})),i.React.createElement(y,{title:"Message Commands"},i.React.createElement(c,{label:"/firstmessage",subLabel:"Get the first message in a channel",value:s.storage.enabledCommands?.firstmessage??!0,onValueChange:function(e){return a("firstmessage",e)}})),i.React.createElement(y,{title:"Credits"},i.React.createElement(w,{label:"Facts Commands",subLabel:"by jdev082"}),i.React.createElement(w,{label:"List Commands",subLabel:"by Kitomanari"}),i.React.createElement(w,{label:"PetPet Command",subLabel:"by wolfieeee"}),i.React.createElement(w,{label:"KonoChan Commands",subLabel:"by btmc727 & Rico040"}),i.React.createElement(w,{label:"FirstMessage Command",subLabel:"by sapphire"})),i.React.createElement(y,{title:"About"},i.React.createElement(w,{label:"All-In-One Commands",subLabel:"A collection of useful commands"})))))}s.storage.factSettings||(s.storage.factSettings={sendAsReply:!0,includeCitation:!1}),s.storage.listSettings||(s.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),s.storage.enabledCommands||(s.storage.enabledCommands={catfact:!0,dogfact:!0,useless:!0,petpet:!0,pluginList:!0,themeList:!0,konoself:!0,konosend:!0,firstmessage:!0});const ge={catfact:Q,dogfact:X,useless:Z,petpet:ie,pluginList:ne,themeList:ae,konoself:oe,konosend:re,firstmessage:ce};let A=[];var me={onLoad:function(){console.log("[All-In-One Commands] Loading plugin...");for(const[n,t]of Object.entries(ge))s.storage.enabledCommands[n]&&A.push(q.registerCommand(t));console.log("[All-In-One Commands] Plugin loaded successfully!")},onUnload:function(){console.log("[All-In-One Commands] Unloading plugin..."),A.forEach(function(n){return n()}),A=[],console.log("[All-In-One Commands] Plugin unloaded successfully!")},settings:fe};return v.default=me,Object.defineProperty(v,"__esModule",{value:!0}),v})({},vendetta.commands,vendetta.plugin,vendetta.metro,vendetta.themes,vendetta.plugins,vendetta.ui,vendetta.metro.common,vendetta.storage,vendetta.metro.common.ReactNative);
|