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 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},ie={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 le(),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}}}},re={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 de(),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}}}},ce={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 ue(),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}}}};async function le(){return{text:"Cats can jump up to 6 times their height.",source:"catfacts.com"}}async function de(){return{text:"Dogs have an exceptional sense of smell.",source:"dogfacts.com"}}async function ue(){return{text:"Bananas are berries, but strawberries aren't.",source:"uselessfacts.com"}}const w={CONTENT:"This list is over 2000 characters. Send anyway?",CONFIRM:"Send",CANCEL:"Cancel"},fe={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:`
`},pe="Nothing to see here, huh...",x="github.com/fres621/vendetta-plugins",h={ENABLED:"\u2705",DISABLED:"\u274C",SELECTED:"\u2705",NOT_SELECTED:"\u274C"},me=p.findByProps("sendMessage","receiveMessage"),E=p.findByProps("sendBotMessage"),F=function(){try{return p.findByStoreName("UserStore").getCurrentUser()?.premiumType===2?4e3:2e3}catch{return 2e3}}(),j=function(e){return Object.keys(e).includes(x)},V=function(e){return Object.values(e).find(function(n){return n.id==x})?.enabled},W=function(e){return e.find(function(n){return n.name===fe.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 me.sendMessage(e,{content:K(n)},void 0,{nonce:t})},q=function(e,n){return[`**My ${e} List | ${n} ${e}s**`,U]};async function ye(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(pe);const u=A(r)>F;if(u&&!j(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:w.CONTENT,confirmText:w.CONFIRM,cancelText:w.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 ge(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)>F;if(r&&!j(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:w.CONTENT,confirmText:w.CONFIRM,cancelText:w.CANCEL,onConfirm:async function(){return await T(o,l)}});await T(o,l)}}catch(t){return console.error("[PluginList] Error:",t),{type:4}}}const he={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:ge,applicationId:"-1",inputType:1,type:1},be={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:ye,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:C}=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 xe(){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(