Module 488626

1,786 characters · in no known chunk
Dependencies
Required by (1)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>S});var i=n(401843),r=n(439372),s=n(616356),a=n(232835),o=n(935208),l=n(17928),u=n(228366),c=n(652896),d=n(763827),_=n(652215);let f={},h={},p=null;function E(){h={},f={}}class m extends l.Ay.Store{initialize(){this.waitFor(d.A)}getPendingRequestForUser(e){return h[e]}}let g=new m(u.h,{STREAM_WATCH:function(e){let{streamKey:t}=e,{ownerId:n}=c.Iy(t);if(null==h[n])return!1;delete h[n]},MESSAGE_CREATE:function(e){let{channelId:t,sendMessageOptions:n,message:i,optimistic:r}=e;if(t!==d.A.getChannelId())return!1;if(r){let e=n?.activityAction?.targetUserId;return null!=e&&(f[i.id]=e,!1)}if(null==i.nonce||i.activity?.type!==_.xL.STREAM_REQUEST)return!1;let s=f[i.nonce];if(null==s)return!1;delete f[i.nonce],h={...h,[s]:i.id}},MESSAGE_DELETE:function(e){let{id:t}=e;for(let[e,n]of(delete f[t],Object.entries(h)))t===n&&delete h[e]},VOICE_CHANNEL_SELECT:function(e){let{channelId:t,currentVoiceChannelId:n}=e;if(t===n)return!1;E()},VOICE_STATE_UPDATES:function(){if(d.A.getWasMoved()){if(d.A.getChannelId()===p)return!1;p=d.A.getChannelId(),E()}else{if(null==p)return!1;p=null}},LOGOUT:E});var A=n(25528),I=n(820672);class T extends r.A{actions={VOICE_STATE_UPDATES:this.handleVoiceStateUpdates};handleVoiceStateUpdates(e){let{voiceStates:t}=e;for(let e of t){if(null==e.channelId||!0!==e.selfStream)continue;let t=g.getPendingRequestForUser(e.userId);if(null==t)continue;let n=a.A.getMessage(e.channelId,t);if(n?.activity?.type!==_.xL.STREAM_REQUEST||n.application?.id==null||o.default.extractTimestamp(t)<Date.now()-I.M||null==(0,A.nn)(e.userId,e.guildId).find(e=>n.application?.id!=null&&e.application_id===n.application.id))continue;let r=s.A.getStreamForUser(e.userId,e.guildId);null!=r&&i.A9(r,{forceMultiple:!0,noFocus:!0})}}}let S=new T}