5 lines
24 KiB
JavaScript
5 lines
24 KiB
JavaScript
(function(N,$,s,r,y,le,d,F,f,L,_){"use strict";function V(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function j(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function G(e,t,n){return t&&j(e.prototype,t),n&&j(e,n),e}const A=le.storage;var u=function(e){return e.Useful="Useful",e.Fixes="Fixes",e.Fun="Fun",e}({});let ce=function(){function e(){V(this,e),this.store=[]}return G(e,[{key:"add",value:function(t){this.store.push(t)}},{key:"unpatch",value:function(){for(const t of this.store)try{t()}catch{}this.store=[]}}]),e}(),h=function(){function e({id:t,label:n,meta:a,settings:o,handlers:i}){V(this,e),this.id=t,this.label=n,this.meta=a,this.settings=o??{},this.handlers=i,this.errors={},this.patches=new ce,this.started=!1,this.listeners=new Set}return G(e,[{key:"storage",get:function(){const t=Object.fromEntries(Object.entries(this.settings).filter(function([,n]){return"default"in n}).map(function([n,a]){return[n,a.default]}));A.modules[this.id]??={enabled:!1,options:t};for(const[n,a]of Object.entries(t)){const o=A.modules[this.id].options;typeof a!=typeof o[n]&&(o[n]=a)}return A.modules[this.id]}},{key:"toggle",value:function(){this.storage.enabled=!this.storage.enabled,this.storage.enabled?this.start():this.stop(),this.refresh()}},{key:"restart",value:function(){this.started&&(this.stop(),this.start(),this.refresh())}},{key:"start",value:function(){if(!this.started){try{this.started=!0,this.handlers.onStart.call(this)}catch(t){this.stop(),this.started=!1;const n=t instanceof Error?t:new Error(String(t));$.logger.error(`[RoseUtils/${this.label}] Failed to start: ${n}`),this.errors.Start=String(n.stack??n),d.showToast(`${this.label} failed to start - see RoseUtils settings for details`,void 0)}this.refresh()}}},{key:"stop",value:function(){if(this.started){try{this.started=!1,this.handlers.onStop.call(this)}catch(t){const n=t instanceof Error?t:new Error(String(t));$.logger.error(`[RoseUtils/${this.label}] Failed to stop cleanly: ${n}`),this.errors.Stop=String(n.stack??n)}finally{this.patches.unpatch()}this.refresh()}}},{key:"refresh",value:function(){this.listeners.forEach(function(t){return t()})}},{key:"useRefresh",value:function(){var t=this;const[,n]=r.React.useReducer(function(a){return~a},0);r.React.useEffect(function(){return t.listeners.add(n),function(){t.listeners.delete(n)}},[])}}]),e}();var ue="d170a10bd3781e4a.png";function D(e,t,n=!1){const a=function(...o){n&&r.FluxDispatcher.unsubscribe(e,a),t(...o)};return r.FluxDispatcher.subscribe(e,a),function(){return r.FluxDispatcher.unsubscribe(e,a)}}const de=s.findByStoreName("SpotifyProtocolStore"),k=s.findByStoreName("SpotifyStore"),fe=s.findByStoreName("UserStore"),{play:z,sync:B}=s.findByProps("play","sync")??{};function pe(e,t,n){if(typeof e=="string")return d.showToast(e,void 0);if(!z||!B)return d.showToast("Couldn't find Spotify's sync action - this feature may be unavailable on your Discord version.",void 0);if(k?.getActivity())return B(t,n);D("SPOTIFY_PLAYER_STATE",function(){return B(t,n)},!0),z(t,n)}function ge(e){const[t,n]=r.React.useReducer(function(l){return~l},0);r.React.useEffect(function(){return D("SPOTIFY_PLAYER_STATE",n)});const a=e.party.id.split(":")[1],o=r.React.useMemo(function(){const l=fe?.getCurrentUser?.()?.id,g=k?.getActivity?.(),m=!!k?.hasConnectedAccount?.(),c=!!k?.getActiveSocketAndDevice?.()||!!de?.isProtocolRegistered?.();return{isYou:l===a,isListeningAlong:g?.party?.id===e.party.id,isPlayable:m&&c}},[a,e,t]);let i=!1;return o.isYou?i="Listen along with someone else, not yourself.":o.isListeningAlong?i="You're already along for this ride.":o.isPlayable||(i="Spotify is not detected"),{disabled:i,userId:a}}function ye(){const[e,t]=r.React.useState(!1);return{loading:e,trigger:function(){return t(!0),setTimeout(function(){return t(!1)},5e3)}}}function he({button:e,activity:t}){const{disabled:n,userId:a}=ge(t),{loading:o,trigger:i}=ye(),l=o&&!n;return React.createElement(r.ReactNative.View,{style:{flexDirection:"row",flex:1}},React.createElement(r.ReactNative.View,{style:{paddingRight:6}},React.createElement(F.Button,{size:"small",text:"",style:[e?.style,{width:32},!!n&&{opacity:.5}],renderIcon:function(){return l?React.createElement(r.ReactNative.ActivityIndicator,{size:"small",color:"#fff"}):React.createElement(r.ReactNative.Image,{source:ue,style:{width:20,height:20,tintColor:"#fff"}})},onPress:function(){return!l&&(pe(n,t,a),!n&&i())}})),React.createElement(r.ReactNative.View,{style:{flexGrow:1}},React.createElement(F.Button,e)))}const Y=s.findByProps("SpotifyPlayButton");var be=new h({id:"spotify-listen-along",label:"Add Listen Along",meta:{sublabel:"Ports the Spotify listen along feature from desktop to mobile in Spotify activities",category:u.Useful},handlers:{onStart(){Y?.SpotifyPlayButton&&this.patches.add(y.after("SpotifyPlayButton",Y,function([e],t){if(t)return r.React.createElement(he,{button:t.props,activity:e?.activity})}))},onStop(){}}});const{View:ve,TouchableOpacity:me,Image:Se}=r.ReactNative,H=s.findByStoreName("SpotifyStore"),Ie=s.findByStoreName("SelectedChannelStore"),Re=s.findByStoreName("DraftStore"),P=s.findByProps("sendMessage","revealMessage"),M=s.findByProps("clearDraft"),we=function(){if(!P?.sendMessage||!M?.clearDraft)return;const e=H?.getActivity?.();if(!e?.party?.id)return;const t=Ie?.getChannelId?.();t&&(P.sendMessage(t,{content:Re?.getDraft?.(t,0)??"",tts:!1,invalidEmojis:[],validNonShortcutEmojis:[]},!0,{activityAction:{activity:e,type:3}}),M.clearDraft(t,0))};function $e(){const[,e]=r.React.useReducer(function(a){return~a},0);r.React.useEffect(function(){return D("SPOTIFY_PLAYER_STATE",e)});const t=!!(P?.sendMessage&&M?.clearDraft&&H?.getActivity?.()?.party?.id),n=f.getAssetByID(f.getAssetIDByName("ic_spotify_white_16px"));return r.React.createElement(ve,{style:{opacity:t?1:.4,paddingHorizontal:8,justifyContent:"center"}},r.React.createElement(me,{disabled:!t,onPress:we},n?.uri?r.React.createElement(Se,{source:{uri:n.uri},style:{width:22,height:22}}):r.React.createElement(r.ReactNative.Text,{style:{color:"#1ED760",fontWeight:"700"}},"\u266B")))}const J=s.findByTypeName("MediaKeyboardListHeader",!1);var Ae=new h({id:"send-spotify-invite",label:"Send Spotify invite",meta:{sublabel:"Adds a button in the chat attachment menu to invite the channel to listen along to Spotify",category:u.Useful},handlers:{onStart(){J&&this.patches.add(y.after("type",J,function(e,t){if(!(!t?.props||!Array.isArray(t.props.children)))return{...t,props:{...t.props,children:[...t.props.children,r.React.createElement($e,{})]}}}))},onStop(){}}});function De(e){const{NativeModules:t}=r.ReactNative,n=t?.DCDChatManager;if(n?.updateRows)return y.before("updateRows",n,function(o){try{const i=JSON.parse(o[1]);e(i),o[1]=JSON.stringify(i)}catch{}});const a=s.findByName("RowManager",!1);return a?.prototype?.generate?y.after("generate",a.prototype,function(o,i){try{e([i])}catch{}}):function(){}}const K=s.findByStoreName("GuildMemberStore");var ke=new h({id:"minimod",label:"Minimod",meta:{sublabel:"Lets you see some moderator-only things, like whether a member is currently timed out",category:u.Fun},settings:{showTimeouts:{label:"Show timeouts",subLabel:"Show member timeout icons in chat",type:"toggle",default:!0}},handlers:{onStart(){!this.storage.options.showTimeouts||!K?.getMember||this.patches.add(De(function(e){if(!e.some(function(n){return"message"in n}))return;const t=Date.now();for(const n of e){if(n.type!==1)continue;const a=K.getMember(n.message.guildId,n.message.authorId)?.communicationDisabledUntil;a&&new Date(a).getTime()>t&&(n.message.communicationDisabled=!0)}}))},onStop(){}}});const Ce=s.findByStoreName("ThemeStore"),Ee=s.find(function(e){return e?.default?.internal?.resolveSemanticColor})?.default?.internal?.resolveSemanticColor??s.find(function(e){return e?.meta?.resolveSemanticColor})?.meta?.resolveSemanticColor??function(){};function q(e,t=Ce?.theme){if(e)try{return Ee(t,e)}catch{return}}const{View:Te,Text:Ne}=r.ReactNative,Q={destructive:{bg:"#F23F42",fg:"#FFFFFF"},default:{bg:"#4E5058",fg:"#FFFFFF"}};function Fe({variant:e="default",children:t}){const n=Q[e]??Q.default;return r.React.createElement(Te,{style:{backgroundColor:n.bg,borderRadius:4,paddingHorizontal:4,paddingVertical:1,marginLeft:4,alignSelf:"center"}},r.React.createElement(Ne,{style:{color:n.fg,fontSize:10,fontWeight:"700",textTransform:"uppercase"}},t))}var Le="f47fd463dcaac61e.png",_e="f944dbd033a60207.png",Be="88eacd3588829ded.png",Pe="4d1aef97fe869aaf.png",Me="3a73d84a21043a5e.png",Ue="8b628d7e3fc05957.png",xe="cb7a2c9b3fb9561c.png",Oe="11d89273b5bd6cc6.png",We="ea31146eb15fdde7.png",Ve="b0d124bd12658047.png",je="cb8b45023e70bb61.png",Ge="a738efc867a225ee.png",ze="cba17334eeaf3198.png",Ye="fead9e69933db668.png",He="fead9e69933db668.png",Je="d6a4e512cdcf1078.png",Ke="9901722947705011.png",qe=function(e){return e.Lock="Lock",e.Warning="Warning",e.Controller="Controller",e}(qe||{});function Qe(e,t){if(e==="Lock")return t?We:Oe;if(e==="Warning")return t?Ke:Je;if(e==="Controller")return Be}const Xe={Lock:["#f0b232","STATUS_WARNING"],Warning:["#f23f43","STATUS_DANGER"],Controller:["#23a55a","STATUS_POSITIVE"]},Ze=[{name:"Announcements",kind:"Lock",base:Le},{name:"Announcements",kind:"Warning",base:_e},{name:"Text",kind:"Lock",base:Ge},{name:"Text",kind:"Warning",base:ze},{name:"Text",kind:"Controller",base:je},{name:"Voice",kind:"Lock",base:Ye},{name:"Voice",kind:"Warning",base:He},{name:"Forum",kind:"Lock",base:Pe},{name:"Forum",kind:"Warning",base:Me},{name:"Stage",kind:"Lock",bottom:!0,base:Ve},{name:"Stage",kind:"Warning",bottom:!0,base:0},{name:"Image",kind:"Lock",bottom:!0,base:Ue},{name:"Image",kind:"Warning",bottom:!0,base:xe}],X=s.findByName("ChannelInfo",!1),Z=s.findByProps("BaseChannelIcon");var et=new h({id:"colorful-channels",label:"Colorful Channels",meta:{sublabel:"Gives channel icons with symbols colors to make them more aesthetically pleasing",category:u.Useful},settings:{nsfwTag:{label:"NSFW tag",subLabel:"Adds a red NSFW tag next to channel names",type:"toggle",default:!0},colorIcons:{label:"Colored icon symbols",subLabel:"Turns locked channel symbols yellow, NSFW channel symbols red",type:"toggle",default:!0},colorIconsFallback:{label:"Fallback colors for colored icon symbols",subLabel:"Uses yellow, red and green colors regardless of theme",type:"toggle",default:!1}},handlers:{onStart(){var e=this;this.storage.options.nsfwTag&&X&&this.patches.add(y.after("default",X,function([{channel:t}],n){return r.React.createElement(r.React.Fragment,{},t?.nsfw_&&r.React.createElement(Fe,{variant:"destructive"},"nsfw"),n)})),this.storage.options.colorIcons&&Z?.BaseChannelIcon&&this.patches.add(y.after("BaseChannelIcon",Z,function([{source:t,style:n}],a){try{const o=typeof t?.original=="number"?f.getAssetByID(t.original)?.name:typeof t=="number"?f.getAssetByID(t)?.name:null;if(!o)return;const i=Ze.find(function(T){return o===`${T.name}${T.kind}Icon`});if(!i)return;const[l,g]=Xe[i.kind],m=Qe(i.kind,i.bottom),c=a?.props?.color?.replace(/-/g,"_")?.toUpperCase(),S=c&&L.semanticColors?.[c]?q(L.semanticColors[c]):void 0,w=r.ReactNative.StyleSheet.flatten([n,a?.props?.style,{width:18,height:18,tintColor:S}]),E=e.storage.options.colorIconsFallback?l:q(L.semanticColors?.[g])??l;return r.React.createElement(r.ReactNative.View,{},r.React.createElement(r.ReactNative.Image,{style:w,source:i.base}),r.React.createElement(r.ReactNative.View,{style:{position:"absolute",right:0,bottom:0}},r.React.createElement(r.ReactNative.Image,{style:{...w,tintColor:E},source:m})))}catch{return}}))},onStop(){}}});const U=s.findByProps("openLazy","hideActionSheet"),{ActionSheetRow:b}=s.findByProps("ActionSheetRow")??{},C=new Set;let I=null;function tt(e,t){return b?r.React.createElement(b,{label:e.label,subLabel:e.sublabel,icon:e.icon?r.React.createElement(b.Icon,{source:f.getAssetIDByName(e.icon)}):void 0,onPress:function(){try{e.onPress(t)}finally{U?.hideActionSheet?.()}},key:e.key}):null}function nt(e){const t=[];for(const n of C)try{for(const a of n(e)){const o=tt(a,e);o&&t.push(o)}}catch{}return t}function at(){return y.before("openLazy",U,function([e,t,n]){t!=="MessageLongPressActionSheet"||!n?.message||e.then(function(a){a.__roseUtilsActiveMessage=n.message,!a.__roseUtilsPatched&&(a.__roseUtilsPatched=!0,y.after("default",a,function(o,i){try{const l=nt(a.__roseUtilsActiveMessage);if(!l.length)return;const g=_.findInReactTree(i,function(c){return Array.isArray(c)&&c[0]?.type?.name==="ActionSheetRowGroup"});if(Array.isArray(g)&&g.length&&b){let c=!1;for(const S of g){const w=_.findInReactTree(S,function(E){return Array.isArray(E)&&E.some(function(T){return T?.type?.name==="ActionSheetRow"})});if(Array.isArray(w)){w.push(...l),c=!0;break}}if(!c&&typeof g.unshift=="function"&&b.Group&&(g.unshift(r.React.createElement(b.Group,{},l)),c=!0),c)return}const m=_.findInReactTree(i,function(c){return Array.isArray(c)&&c.length>0&&c.every(function(S){return typeof S?.props?.label=="string"&&typeof S?.props?.onPress=="function"})});Array.isArray(m)&&m.push(...l)}catch{}}))})})}function p(e){return!I&&U&&(I=at()),C.add(e),function(){C.delete(e),C.size===0&&I&&(I(),I=null)}}const rt=s.findByProps("DeveloperMode","DarkSidebar"),ee=s.findByStoreName("PresenceStore");function ot(e){const t=e?.interaction??e?.interactionMetadata??e?.interaction_metadata;return t?.id?{id:String(t.id),name:t.name}:null}function it(e){const t=ot(e);return t?[{key:"rose-utils-copy-command-id",label:"Copy Command ID",sublabel:t.name?`/${t.name}`:"Slash command interaction",icon:"ic_copy_24px",onPress:function(){r.clipboard.setString(t.id),d.showToast("Copied command ID to clipboard",f.getAssetIDByName("ic_copy_24px"))}}]:[]}function st(e){if(!ee?.getActivities)return[];const t=e?.author?.id;if(!t)return[];let n;try{n=ee.getActivities(t)}catch{return[]}if(!Array.isArray(n))return[];const a=n.filter(function(o){return o?.application_id??o?.applicationId});return a.length?a.map(function(o,i){const l=String(o.application_id??o.applicationId);return{key:`rose-utils-copy-activity-id-${i}`,label:a.length>1?`Copy Activity ID (${o.name??i+1})`:"Copy Activity/Game ID",sublabel:o.name,icon:"ic_copy_24px",onPress:function(){r.clipboard.setString(l),d.showToast(`Copied ${o.name??"activity"} ID to clipboard`,f.getAssetIDByName("ic_copy_24px"))}}}):[]}var lt=new h({id:"enforce-developer-mode",label:"Developer Mode",meta:{sublabel:"Turns on Discord's real Developer Mode (all its native Copy ID options) and adds extra copy-ID tools slash commands and activities don't get natively",category:u.Useful},settings:{keepNativeOn:{label:"Keep native Developer Mode on",subLabel:"Re-asserts Discord's own Developer Mode setting - it tends to reset itself on Revenge-based clients",type:"toggle",default:!0},copyCommandId:{label:"Copy Command ID",subLabel:"Adds a row to the message long-press menu for messages sent via a slash command",type:"toggle",default:!0},copyActivityId:{label:"Copy Activity/Game ID",subLabel:"Adds a row to the message long-press menu to copy the author's current game/activity application ID (not every activity type has one, e.g. a plain custom status)",type:"toggle",default:!0}},handlers:{onStart(){if(this.storage.options.keepNativeOn){const e=rt?.DeveloperMode;if(e?.getSetting&&e?.updateSetting){const t=function(){try{e.getSetting()||e.updateSetting(!0)}catch{}};t(),this.patches.add(D("USER_SETTINGS_PROTO_UPDATE",t));const n=setInterval(t,5e3);this.patches.add(function(){return clearInterval(n)})}}this.storage.options.copyCommandId&&this.patches.add(p(it)),this.storage.options.copyActivityId&&this.patches.add(p(st))},onStop(){}}});const v="ic_copy_24px";function R(e,t){r.clipboard.setString(e),d.showToast(t,f.getAssetIDByName(v))}function ct(e){const t=e?.webhookId??e?.webhook_id;return t?[{key:"rose-utils-copy-webhook-id",label:"Copy Webhook ID",icon:v,onPress:function(){return R(String(t),"Copied webhook ID to clipboard")}}]:[]}function ut(e){const t=e?.nonce;return t?[{key:"rose-utils-copy-nonce",label:"Copy Nonce",icon:v,onPress:function(){return R(String(t),"Copied nonce to clipboard")}}]:[]}function dt(e){const t=e?.attachments;if(!Array.isArray(t)||!t.length)return[];const n=t.map(function(a){return a?.id}).filter(Boolean);return n.length?[{key:"rose-utils-copy-attachment-ids",label:n.length>1?`Copy Attachment IDs (${n.length})`:"Copy Attachment ID",icon:v,onPress:function(){return R(n.join(", "),`Copied ${n.length} attachment ID${n.length===1?"":"s"} to clipboard`)}}]:[]}function ft(e){const t=e?.messageReference??e?.message_reference,n=t?.messageId??t?.message_id;return n?[{key:"rose-utils-copy-referenced-id",label:"Copy Replied-to Message ID",icon:v,onPress:function(){return R(String(n),"Copied replied-to message ID to clipboard")}}]:[]}function pt(e){return e?.id?[{key:"rose-utils-copy-debug-info",label:"Copy Message Debug Info",sublabel:"Type, flags, and timestamps",icon:v,onPress:function(){const t={id:e.id,channelId:e.channelId??e.channel_id,type:e.type,flags:e.flags,timestamp:e.timestamp,editedTimestamp:e.editedTimestamp??e.edited_timestamp};R(JSON.stringify(t,null,2),"Copied message debug info to clipboard")}}]:[]}var gt=new h({id:"message-dev-tools",label:"Message Dev Tools",meta:{sublabel:"Extra copy-ID rows in the message long-press menu, beyond what Discord's Developer Mode gives you natively",category:u.Useful},settings:{copyWebhookId:{label:"Copy Webhook ID",subLabel:"For messages sent by a webhook",type:"toggle",default:!0},copyNonce:{label:"Copy Nonce",subLabel:"The client-generated ID used to match an optimistic send to its real message",type:"toggle",default:!0},copyAttachmentIds:{label:"Copy Attachment ID(s)",type:"toggle",default:!0},copyReferencedId:{label:"Copy Replied-to Message ID",type:"toggle",default:!0},copyDebugInfo:{label:"Copy Message Debug Info",subLabel:"Type, flags, and creation/edit timestamps as JSON",type:"toggle",default:!0}},handlers:{onStart(){const e=this.storage.options;e.copyWebhookId&&this.patches.add(p(ct)),e.copyNonce&&this.patches.add(p(ut)),e.copyAttachmentIds&&this.patches.add(p(dt)),e.copyReferencedId&&this.patches.add(p(ft)),e.copyDebugInfo&&this.patches.add(p(pt))},onStop(){}}});const yt=1420070400000n;function te(e){const t=e.trim();if(!/^\d{15,20}$/.test(t))return null;try{const n=(BigInt(t)>>22n)+yt;return new Date(Number(n))}catch{return null}}function ht(e){return te(e)?.toISOString()??null}var bt=new h({id:"snowflake-tools",label:"Snowflake Tools",meta:{sublabel:"Decode any Discord ID's creation timestamp - useful after copying an ID with Developer Mode",category:u.Useful},settings:{decodeClipboard:{label:"Decode ID(s) in clipboard",subLabel:"Copy one or more Discord IDs first (one per line, or comma-separated), then tap this",type:"button",action(){r.clipboard.getString().then(function(e){const t=e.split(/[\s,]+/).map(function(o){return o.trim()}).filter(Boolean);if(!t.length){d.showToast("Clipboard is empty",void 0);return}const n=t.map(function(o){const i=ht(o);return i?`${o} -> ${i}`:`${o} -> not a valid snowflake`}),a=n.join(`
|
|
`);r.clipboard.setString(a),d.showToast(`Decoded ${n.length} ID${n.length===1?"":"s"} - result copied`,f.getAssetIDByName("ic_copy_24px"))})}}},handlers:{onStart(){},onStop(){}}});const ne=s.findByStoreName("GuildStore"),ae=s.findByStoreName("RelationshipStore"),re=s.findByStoreName("GuildMemberStore"),vt=s.findByStoreName("UserStore"),x="ic_copy_24px";function oe(e,t){r.clipboard.setString(e),d.showToast(t,f.getAssetIDByName(x))}function ie(e){return e?.guildId??e?.guild_id??null}function mt(e){const t=ie(e);if(!t||!ne?.getGuild)return[];const n=ne.getGuild(t);return n?[{key:"rose-utils-copy-server-info",label:"Copy Server Info",sublabel:n.name,icon:x,onPress:function(){const a={id:t,name:n.name,ownerId:n.ownerId,createdAt:te(t)?.toISOString(),boostTier:n.premiumTier,boostCount:n.premiumSubscriberCount,verificationLevel:n.verificationLevel,vanityURLCode:n.vanityURLCode,description:n.description,features:n.features};oe(JSON.stringify(a,null,2),"Copied server info to clipboard")}}]:[]}function St(e){const t=ie(e);if(!t||!ae?.getFriendIDs||!re?.getMember)return[];let n;try{n=ae.getFriendIDs()}catch{return[]}return!Array.isArray(n)||!n.length?[]:[{key:"rose-utils-copy-friends-in-server",label:"Copy Friends In This Server",sublabel:"Only counts friends already loaded into this server's member list this session",icon:x,onPress:function(){const a=n.filter(function(o){try{return!!re.getMember(t,o)}catch{return!1}}).map(function(o){return vt?.getUser?.(o)?.username??o});oe(a.length?a.join(", "):"(none found - they may just not be loaded into the member list yet)",`Copied ${a.length} friend${a.length===1?"":"s"} in this server to clipboard`)}}]}var It=new h({id:"server-info-tools",label:"Server Info Tools",meta:{sublabel:"Adds Copy Server Info and Copy Friends In This Server rows to the message long-press menu",category:u.Useful},settings:{copyServerInfo:{label:"Copy Server Info",subLabel:"Boost tier, verification level, features, vanity URL, creation date, and more",type:"toggle",default:!0},copyFriendsInServer:{label:"Copy Friends In This Server",subLabel:"Cross-references your friends list against this server's cached member list",type:"toggle",default:!0}},handlers:{onStart(){const e=this.storage.options;e.copyServerInfo&&this.patches.add(p(mt)),e.copyFriendsInServer&&this.patches.add(p(St))},onStop(){}}}),O=[be,Ae,ke,et,lt,gt,bt,It];const{ScrollView:Rt,View:wt}=r.ReactNative;function $t({children:e}){return r.React.createElement(Rt,{style:{flex:1}},e,r.React.createElement(wt,{style:{height:24}}))}const{View:At,Text:Dt}=r.ReactNative;function kt({children:e,style:t}){return r.React.createElement(At,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},t]},r.React.createElement(Dt,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},e))}const{FormSection:Ct,FormSwitchRow:se,FormRow:W}=F.Forms;function Et(e,t){return typeof e.subLabel=="function"?e.subLabel(t):e.subLabel}function Tt({module:e,settingKey:t}){const n=e.settings[t];if(n.predicate&&!n.predicate.call(e))return null;const a=e.storage.options[t],o=Et(n,a),i=!e.storage.enabled;return n.type==="toggle"?r.React.createElement(se,{label:n.label,subLabel:o,value:!!a,disabled:i,onValueChange:function(l){e.storage.options[t]=l,e.restart()}}):n.type==="button"?r.React.createElement(W,{label:n.label,subLabel:o,disabled:i,onPress:function(){return n.action.call(e)}}):r.React.createElement(W,{label:n.label,subLabel:[o,a].filter(Boolean).join(" - "),disabled:i,onPress:function(){const l=n.choices.indexOf(a);e.storage.options[t]=n.choices[(l+1)%n.choices.length],e.restart()}})}function Nt({module:e}){e.useRefresh();const t=Object.entries(e.errors);return r.React.createElement(Ct,{title:e.label},r.React.createElement(se,{label:"Enabled",subLabel:e.meta.sublabel,value:!!e.storage.enabled,onValueChange:function(){return e.toggle()}}),e.storage.enabled&&Object.keys(e.settings).map(function(n){return r.React.createElement(Tt,{key:n,module:e,settingKey:n})}),t.length>0&&r.React.createElement(W,{label:`${t.length} error${t.length===1?"":"s"} - tap to copy`,onPress:function(){const n=t.map(function([a,o]){return`[${e.label}] ${a}
|
|
${o}`}).join(`
|
|
|
|
`);r.clipboard.setString(n),d.showToast("Copied - paste this when reporting the issue",void 0)}}))}const Ft=[u.Useful,u.Fixes,u.Fun];function Lt(){return r.React.createElement($t,null,r.React.createElement(kt,null,"RoseUtils is a collection of small, independent utilities - toggle whichever ones you want. Fork of nexpid's NexxUtils, with fixes for lookups that broke on newer Discord versions. If a module shows an error below, tap it to copy the details for a bug report."),Ft.flatMap(function(e){return O.filter(function(t){return t.meta.category===e}).map(function(t){return r.React.createElement(Nt,{key:t.id,module:t})})}))}var _t={onLoad(){A.modules??={};for(const e of O)try{e.storage.enabled&&e.start()}catch(t){$.logger.error(`[RoseUtils] Failed to start "${e.label}" on load: ${t}`)}},onUnload(){for(const e of O)try{e.stop()}catch(t){$.logger.error(`[RoseUtils] Failed to stop "${e.label}" cleanly: ${t}`)}},settings:Lt};return N.default=_t,Object.defineProperty(N,"__esModule",{value:!0}),N})({},vendetta,vendetta.metro,vendetta.metro.common,vendetta.patcher,vendetta.plugin,vendetta.ui.toasts,vendetta.ui.components,vendetta.ui.assets,vendetta.ui,vendetta.utils);
|