vd-plugins/Commands/index.js

8 lines
20 KiB
JavaScript
Raw Normal View History

(function(I,ne,s,p,N,g,D,i,ae,se,oe){"use strict";const ie=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}},re=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},ce=async function(){const e=await(await fetch("https://catfact.ninja/fact")).json();return{text:e.fact,length:e.length}},le=async function(e){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${e.replace("webp","png")}`)).json()},B=p.findByProps("sendMessage"),P=function(e){let n=e.text;return s.storage.factSettings?.includeCitation&&e.source&&(n+=`
2025-09-27 19:17:53 +02:00
Source: ${e.source}`),n},de={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,n){try{const t=await ce(),a=Date.now().toString();return B.sendMessage(n.channel.id,{content:P(t)},void 0,{nonce:a}),{type:4}}catch(t){return console.error("[CatFact] Error:",t),{type:4}}}},ue={name:"dogfact",displayName:"dogfact",description:"Sends a dog fact.",displayDescription:"Sends a dog fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,n){try{const t=await re(),a=Date.now().toString();return B.sendMessage(n.channel.id,{content:P(t)},void 0,{nonce:a}),{type:4}}catch(t){return console.error("[DogFact] Error:",t),{type:4}}}},fe={name:"useless",displayName:"useless",description:"Sends a useless fact.",displayDescription:"Sends a useless fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,n){try{const t=await ie(),a=Date.now().toString();return B.sendMessage(n.channel.id,{content:P(t)},void 0,{nonce:a}),{type:4}}catch(t){return console.error("[UselessFact] Error:",t),{type:4}}}},C={CONTENT:"This list is over 2000 characters. Send anyway?",CONFIRM:"Send",CANCEL:"Cancel"},pe={DETAILED:"detailed"},U="",v={SLM_NOT_INSTALLED:"This list is over 2000 characters. Install the Split Large Messages plugin to send it.",SLM_NOT_ENABLED:"This list is over 2000 characters. Enable the Split Large Messages plugin to send it."},_={SEMICOL:"; ",NEW_LINE:`
`},me="Nothing to see here, huh...",j="github.com/fres621/vendetta-plugins",h={ENABLED:"\u2705",DISABLED:"\u274C",SELECTED:"\u2705",NOT_SELECTED:"\u274C"},ye=p.findByProps("sendMessage","receiveMessage"),E=p.findByProps("sendBotMessage"),x=function(){try{return p.findByStoreName("UserStore").getCurrentUser()?.premiumType===2?4e3:2e3}catch{return 2e3}}(),F=function(e){return Object.keys(e).includes(j)},V=function(e){return Object.values(e).find(function(n){return n.id==j})?.enabled},W=function(e){return e.find(function(n){return n.name===pe.DETAILED})?.value??!1},$=function(e){return!e||!Array.isArray(e)||e.length===0?"Unknown":e.filter(function(n){return n&&(typeof n=="string"||typeof n=="object"&&n.name)}).map(function(n){return typeof n=="string"?n:n.name||"Unknown"}).join(_.SEMICOL)||"Unknown"},K=function(e){return e.join(_.NEW_LINE).trimEnd()},A=function(e){return K(e).length},T=async function(e,n){const t=Date.now().toString();await ye.sendMessage(e,{content:K(n)},void 0,{nonce:t})},q=function(e,n){return[`**My ${e} List | ${n} ${e}s**`,U]};async function ge(e,n){try{const t=W(e),a=s.storage.themeListAlwaysDetailed??!1;if(!N.themes||typeof N.themes!="object"){const f=n.channel.id;return E.sendBotMessage(f,"No themes found or themes not loaded yet."),{type:4}}const o=Object.values(N.themes),l=n.channel.id,r=q("Theme",Object.keys(N.themes).length);if(o.length)for(const f of o){if(!f||typeof f!="object")continue;const{selected:c,data:d,id:y}=f,S=d?.name||"Unknown Theme",L=d?.description||"No description",M=d?.authors;t||a?r.push(`> **Name**: ${S}`,`> **Selected**: ${c?h.SELECTED:h.NOT_SELECTED}`,`> **Description**: ${L}`,`> **Authors**: ${$(M)}`,`> **[Install!](${y||"unknown"})**`,U):r.push(`> ${c?h.SELECTED:h.NOT_SELECTED} **${S}** by ${$(M)}`)}else r.push(me);const u=A(r)>x;if(u&&!F(g.plugins))E.sendBotMessage(l,v.SLM_NOT_INSTALLED);else if(u&&!V(g.plugins))E.sendBotMessage(l,v.SLM_NOT_ENABLED);else{if(A(r)>2e3)return D.alerts.showConfirmationAlert({content:C.CONTENT,confirmText:C.CONFIRM,cancelText:C.CANCEL,onConfirm:async function(){return await T(l,r)}});await T(l,r)}}catch(t){return console.error("[ThemeList] Error:",t),{type:4}}}async function he(e,n){try{const t=W(e),a=s.storage.pluginListAlwaysDetailed??!1,o=n.channel.id;if(!g.plugins||typeof g.plugins!="object")return E.sendBotMessage(o,"No plugins found or plugins not loaded yet."),{type:4};const l=q("Plugin",Object.keys(g.plugins).length);for(const u of Object.values(g.plugins)){if(!u||typeof u!="object")continue;const{enabled:f,manifest:c,id:d}=u,y=c?.name||"Unknown Plugin",S=c?.description||"No description",L=c?.authors;t||a?l.push(`> **Name**: ${y}`,`> **Status**: ${f?h.ENABLED:h.DISABLED}`,`> **Description**: ${S}`,`> **Authors**: ${$(L)}`,`> **[Install!](${d||"unknown"})**`,U):l.push(`> ${f?h.ENABLED:h.DISABLED} **${y}** by ${$(L)}`)}const r=A(l)>x;if(r&&!F(g.plugins))E.sendBotMessage(o,v.SLM_NOT_INSTALLED);else if(r&&!V(g.plugins))E.sendBotMessage(o,v.SLM_NOT_ENABLED);else{if(A(l)>2e3)return D.alerts.showConfirmationAlert({content:C.CONTENT,confirmText:C.CONFIRM,cancelText:C.CANCEL,onConfirm:async function(){return await T(o,l)}});await T(o,l)}}catch(t){return console.error("[PluginList] Error:",t),{type:4}}}const be={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:he,applicationId:"-1",inputType:1,type:1},we={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:ge,applicationId:"-1",inputType:1,type:1
`];const a=Be();Object.keys(a).forEach(function(r){const u=s.storage[r.toLowerCase()],f=e.find(function(c){return c.name==r.toLowerCase()})?.value??u;(f||u)&&!(u&&!f)&&(t.push(`[**${r}**]`),Object.keys(a[r]).forEach(function(c){t.push(`> ${c}: ${a[r][c]}`)}))});const o=s.storage.ephemeral,l=e.find(function(r){return r.name=="ephemeral"})?.value??o;if((l||o)&&!(o&&!l))return Re.sendBotMessage(n.channel.id,t.join(`
`)),{type:4};{const r=Date.now().toString();return Te.sendMessage(n.channel.id,{content:t.join(`
`)},void 0,{nonce:r}),{type:4}}}catch(t){return console.error("[Sysinfo] Error:",t),{type:4}}}const Ue={name:"sysinfo",displayName:"sysinfo",description:"Display system information",displayDescription:"Display system information",options:[{name:"ephemeral",displayName:"ephemeral",description:"Keep sysinfo ephemeral (default: true)",displayDescription:"Keep sysinfo ephemeral (default: true)",type:5,required:!1},...J.slice(0,-1).map(function(e){return{name:e,displayName:e,description:`Display the ${e} section. Set default in settings.`,displayDescription:`Display the ${e} section. Set default in settings.`,type:5,required:!1}})],execute:Pe,applicationId:"-1",inputType:1,type:1},{ScrollView:Oe}=p.findByProps("ScrollView"),{TableRowGroup:b,TableSwitchRow:m,Stack:_e,TableRow:w}=p.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,sysinfo:!0}),s.storage.pendingRestart||(s.storage.pendingRestart=!1);function je(){se.useProxy(s.storage);const[e,n]=i.React.useReducer(function(a){return a+1},0);i.React.useEffect(function(){return function(){s.storage.pendingRestart&&(s.storage.pendingRestart=!1,D.alerts.showConfirmationAlert({title:"Restart Required",content:"You have made changes to commands. Please restart Discord to apply these changes.",confirmText:"Okay",cancelText:null}))}},[]);const t=function(a,o){s.storage.enabledCommands[a]=o,s.storage.pendingRestart=!0,n()};return i.React.createElement(oe.View,{style:{flex:1}},i.React.createElement(Oe,{style:{flex:1},contentContainerStyle:{paddingBottom:38}},i.React.createElement(_e,{spacing:8},i.React.createElement(b,{title:"Facts Commands"},i.React.createElement(m,{label:"Send as Reply",subLabel:"Send facts as a reply to the command message",value:s.storage.factSettings?.sendAsReply??!0,onValueChange:function(a){s.storage.factSettings.sendAsReply=a,n()}}),i.React.createElement(m,{label:"Include Source Citation",subLabel:"Include the source of facts when available",value:s.storage.factSettings?.includeCitation??!1,onValueChange:function(a){s.storage.factSettings.includeCitation=a,n()}}),i.React.createElement(m,{label:"/catfact",subLabel:"Get random cat facts",value:s.storage.enabledCommands?.catfact??!0,onValueChange:function(a){return t("catfact",a)}}),i.React.createElement(m,{label:"/dogfact",subLabel:"Get random dog facts",value:s.storage.enabledCommands?.dogfact??!0,onValueChange:function(a){return t("dogfact",a)}}),i.React.createElement(m,{label:"/useless",subLabel:"Get random useless facts",value:s.storage.enabledCommands?.useless??!0,onValueChange:function(a){return t("useless",a)}})),i.React.createElement(b,{title:"List Commands"},i.React.createElement(m,{label:"Always Send Detailed Plugin List",subLabel:"Always use detailed mode when listing plugins",value:s.storage.listSettings?.pluginListAlwaysDetailed??!1,onValueChange:function(a){s.storage.listSettings.pluginListAlwaysDetailed=a,n()}}),i.React.createElement(m,{label:"Always Send Detailed Theme List",subLabel:"Always use detailed mode when listing themes",value:s.storage.listSettings?.themeListAlwaysDetailed??!1,onValueChange:function(a){s.storage.listSettings.themeListAlwaysDetailed=a,n()}}),i.React.createElement(m,{label:"/plugin-list",subLabel:"List all installed plugins",value:s.storage.enabledCommands?.pluginList??!0,onValueChange:function(a){return t("pluginList",a)}}),i.React.createElement(m,{label:"/theme-list",subLabel:"List all installed themes",value:s.storage.enabledCommands?.themeList??!0,onValueChange:function(a){return t("themeList",a)}})),i.React.createElement(b,{title:"Image Commands"},i.React.createElement(m,{label:"/petpet",subLabel:"Create pet-pet GIF of a user",value:s.storage.enabledCommands?.petpet??!0,onValueChange:function(a){return t(