vd-plugins/Commands/index.js

5 lines
16 KiB
JavaScript
Raw Normal View History

2025-09-27 23:47:44 +02:00
(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+=`
2025-09-27 19:17:53 +02:00
2025-09-27 23:47:44 +02:00
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:s