vd-plugins/Commands/index.js

8 lines
21 KiB
JavaScript
Raw Normal View History

(function(A,H,s,g,C,v,r,z,X,Y){"use strict";const J=g.findByProps("sendMessage"),Q=function(t){return![4,10,11,12,13,15].includes(t)},y=function(t,n,a,e,o){if(!n)return{type:4};if(o)return{type:4,data:{content:n,flags:64}};try{const i={content:n,...a&&e?.factSettings?.sendAsReply?{messageReference:{messageId:a}}:{}},d=(BigInt(Date.now())*BigInt(4194304)+BigInt(Math.floor(Math.random()*4194304))).toString();return J.sendMessage(t,i,void 0,{nonce:d}),{type:4}}catch(i){return console.error("[Commands] Message send failed:",i),{type:4}}},h=function(t){return Q(t.channel.type)?null:{type:4,data:{content:"This command cannot be used in threads, forum channels, or voice channels.",flags:64}}},Z=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}},ee=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},te=async function(){const t=await(await fetch("https://catfact.ninja/fact")).json();return{text:t.fact,length:t.length}},ne=async function(t){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${t.replace("webp","png")}`)).json()},M=function(t){let n=t.text;return s.storage.factSettings?.includeCitation&&t.source&&(n+=`
2025-09-27 19:17:53 +02:00
Source: ${t.source}`),n},ae={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 a=h(n);if(a)return a;try{const e=await te();return y(n.channel.id,M(e),n.message?.id,s.storage)}catch(e){return console.error("[CatFact] Error:",e),{type:4}}}},se={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 a=h(n);if(a)return a;try{const e=await ee();return y(n.channel.id,M(e),n.message?.id,s.storage)}catch(e){return console.error("[DogFact] Error:",e),{type:4}}}},oe={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 a=h(n);if(a)return a;try{const e=await Z();return y(n.channel.id,M(e),n.message?.id,s.storage)}catch(e){return console.error("[UselessFact] Error:",e),{type:4}}}},N="github.com/fres621/vendetta-plugins",b={ENABLED:"\u2705",DISABLED:"\u274C",SELECTED:"\u2705",NOT_SELECTED:"\u274C"},D=function(t){return!t||t.length===0?"Unknown":t.map(function(n){return n.name}).join(", ")},L=function(t){return t.join(`
`)},I=function(t){return L(t).length},k=function(){return Object.values(C.plugins).some(function(t){return t.id===N})},P=function(){return Object.values(C.plugins).find(function(t){return t.id===N})?.enabled??!1},B=function(){return v.alerts.showConfirmationAlert({title:"Install Split Large Messages Plugin",content:"This list is over 2000 characters. Install the Split Large Messages plugin to send it.",confirmText:"Install",cancelText:"Cancel",onConfirm:function(){}})},x=function(){return v.alerts.showConfirmationAlert({title:"Enable Split Large Messages Plugin",content:"This list is over 2000 characters. Enable the Split Large Messages plugin to send it.",confirmText:"Enable",cancelText:"Cancel",onConfirm:function(){const t=Object.values(C.plugins).find(function(n){return n.id===N});t&&(t.enabled=!0)}})};async function re(t,n){const a=s.storage.listSettings?.pluginListAlwaysDetailed??!1,e=[`**My Plugin List | ${Object.keys(C.plugins).length} Plugins**`,""];for(const o of Object.values(C.plugins)){const{enabled:i,manifest:d,id:c}=o,{name:m,description:u,authors:l}=d;t||a?e.push(`> **Name**: ${m}`,`> **Status**: ${i?b.ENABLED:b.DISABLED}`,`> **Description**: ${u}`,`> **Authors**: ${D(l)}`,`> **[Install!](${c})**`,""):e.push(`> ${i?b.ENABLED:b.DISABLED} **${m}** by ${D(l)}`)}return I(e)>2e3?k()?P()?v.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return y(n.channel.id,L(e))}}):x():B():y(n.channel.id,L(e))}async function ie(t,n){const a=s.storage.themeListAlwaysDetailed??!1,e=[`**My Theme List | ${Object.keys(C.themes).length} Themes**`,""],o=Object.values(C.themes);if(o.length)for(const i of o){const{selected:d,data:c,id:m}=i,{name:u,description:l,authors:f}=c;t||a?e.push(`> **Name**: ${u}`,`> **Selected**: ${d?b.SELECTED:b.NOT_SELECTED}`,`> **Description**: ${l}`,`> **Authors**: ${D(f)}`,`> **[Install!](${m})**`,""):e.push(`> ${d?b.SELECTED:b.NOT_SELECTED} **${u}** by ${D(f)}`)}else e.push("Nothing to see here, huh...");return I(e)>2e3?k()?P()?v.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return y(n.channel.id,L(e))}}):x():B():y(n.channel.id,L(e))}const ce={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 a=h(n);if(a)return a;try{const e=t.find(function(o){return o.name==="detailed"})?.value??!1;return re(e,n)}catch(e){return console.error("[PluginList] Error:",e),{type:4}}},applicationId:"-1",inputType:1,type:1},le={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 a=h(n);if(a)return a;try{const e=t.find(function(o){return o.name==="detailed"})?.value??!1;return ie(e,n)}catch(e){return console.error("[ThemeList] Error:",e),{type:4}}},applicationId:"-1",inputType:1,type:1},de=g.findByStoreName("UserStore"),ue={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 a=h(n);if(a)return a;try{const e=(await de.getUser(t[0].value)).getAvatarURL(512),o=await ne(e);return y(n.channel.id,o.url,n.message?.id)}catch(e){return console.error("[Pe
`];const o=De();Object.keys(o).forEach(function(c){const m=s.storage[c.toLowerCase()],u=t.find(function(l){return l.name==c.toLowerCase()})?.value??m;(u||m)&&!(m&&!u)&&(e.push(`[**${c}**]`),Object.keys(o[c]).forEach(function(l){e.push(`> ${l}: ${o[c][l]}`)}))});const i=s.storage.ephemeral,d=t.find(function(c){return c.name=="ephemeral"})?.value??i;if((d||i)&&!(i&&!d))return Se.sendBotMessage(n.channel.id,e.join(`
`)),{type:4};{const c=$e();return Ce.sendMessage(n.channel.id,{content:e.join(`
`)},void 0,{nonce:c}),{type:4}}}catch(e){return console.error("[Sysinfo] Error:",e),{type:4}}}const Ae={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},..._.slice(0,-1).map(function(t){return{name:t,displayName:t,description:`Display the ${t} section. Set default in settings.`,displayDescription:`Display the ${t} section. Set default in settings.`,type:5,required:!1}})],execute:Re,applicationId:"-1",inputType:1,type:1},{ScrollView:Me}=g.findByProps("ScrollView"),{TableRowGroup:w,TableSwitchRow:p,Stack:Ne,TableRow:S}=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,sysinfo:!0}),s.storage.pendingRestart||(s.storage.pendingRestart=!1);function Te(){X.useProxy(s.storage);const[t,n]=r.React.useReducer(function(e){return e+1},0);r.React.useEffect(function(){return function(){s.storage.pendingRestart&&(s.storage.pendingRestart=!1,v.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,n()};return r.React.createElement(Y.View,{style:{flex:1}},r.React.createElement(Me,{style:{flex:1},contentContainerStyle:{paddingBottom:38}},r.React.createElement(Ne,{spacing:8},r.React.createElement(w,{title:"Facts Commands"},r.React.createElement(p,{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,n()}}),r.React.createElement(p,{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,n()}}),r.React.createElement(p,{label:"/catfact",subLabel:"Get random cat facts",value:s.storage.enabledCommands?.catfact??!0,onValueChange:function(e){return a("catfact",e)}}),r.React.createElement(p,{label:"/dogfact",subLabel:"Get random dog facts",value:s.storage.enabledCommands?.dogfact??!0,onValueChange:function(e){return a("dogfact",e)}}),r.React.createElement(p,{label:"/useless",subLabel:"Get random useless facts",value:s.storage.enabledCommands?.useless??!0,onValueChange:function(e){return a("useless",e)}})),r.React.createElement(w,{title:"List Commands"},r.React.createElement(p,{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,n()}}),r.React.createElement(p,{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,n()}}),r.React.createElement(p,{label:"/plugin-list",subLabel:"List all installed plugins",value:s.storage.enabledCommands?.pluginList??!0,onValueChange:function(e){return a("pluginList",e)}}),r.React.createElement(p,{label:"/theme-list",subLabel:"List all installed themes",value:s.storage.enabledCommands?.themeList??!0,onValueChange:function(e){return a("themeList",e)}})),r.React.createElement(w,{title:"Image Commands"},r.React.createElement(p,{label:"/petpet",subLabel:"Create pet-pet GIF of a user",value:s.storage.enabledCommands?.petpet??!0,onValueChange:function(e){return a("p