private async Task DiscordShardedClientOnVoiceServerUpdated(SocketVoiceServer arg)
 {
     if (VoiceServerUpdated != null)
     {
         await VoiceServerUpdated(this, arg).ConfigureAwait(false);
     }
 }
Beispiel #2
0
 public ConnectionInfo(SocketVoiceServer voiceServer, ulong userId, string sessionId)
 {
     GuildId   = voiceServer.Guild.Id;
     UserId    = userId;
     Token     = voiceServer.Token;
     Endpoint  = voiceServer.Endpoint;
     SessionId = sessionId;
 }
Beispiel #3
0
 private async Task VoiceServerUpdate(SocketVoiceServer voiceServer)
 {
     await Lavalink.VoiceServerUpdateAsync(new VoiceServerUpdate {
         Endpoint = voiceServer.Endpoint,
         GuildID  = voiceServer.Guild.Id,
         Token    = voiceServer.Token
     });
 }
Beispiel #4
0
        private Task OnVoiceServerUpdated(SocketVoiceServer server)
        {
            if (!server.Guild.HasValue || !this.Players.TryGetValue(server.Guild.Id, out LavaPlayer player))
            {
                return(Task.CompletedTask);
            }

            VoiceServerPayload update = new VoiceServerPayload(server, player.CachedState.VoiceSessionId);

            return(this._socketHelper.SendPayloadAsync(update));
        }
Beispiel #5
0
        private Task OnVSU(SocketVoiceServer server)
        {
            if (!server.Guild.HasValue)
            {
                return(Task.CompletedTask);
            }

            if (!_players.TryGetValue(server.Guild.Id, out _))
            {
                return(Task.CompletedTask);
            }

            var voiceUpdate = new VoicePayload(server, _voiceState);

            LavaSocket.SendPayload(voiceUpdate);
            return(Task.CompletedTask);
        }
Beispiel #6
0
        internal async Task UpdateSessionAsync(SessionChange change, object changeData = null)
        {
            switch (change)
            {
            case SessionChange.Connect:
            {
                SocketVoiceServer voiceServer = (SocketVoiceServer)changeData;
                JObject           eventData   = new JObject();
                eventData.Add("token", voiceServer.Token);
                eventData.Add("guild_id", voiceServer.Guild.Id.ToString());
                eventData.Add("endpoint", voiceServer.Endpoint);

                JObject data = new JObject();
                data.Add("op", "voiceUpdate");
                data.Add("guildId", voiceServer.Guild.Id.ToString());
                data.Add("sessionId", sessionId);
                data.Add("event", eventData);

                await manager.GetWebSocket().SendAsync(data.ToString());

                break;
            }

            case SessionChange.Disconnect:
            {
                ulong guildId = (ulong)changeData;

                JObject data = new JObject();
                data.Add("op", "destroy");
                data.Add("guildId", guildId.ToString());

                await manager.GetWebSocket().SendAsync(data.ToString());

                break;
            }

            case SessionChange.Moved:
            {
                VoiceChannel = (IVoiceChannel)changeData;

                break;
            }
            }
        }
        internal async Task UpdateSessionAsync(SessionChange change, object changeData = null)
        {
            switch (change)
            {
            case SessionChange.Connect:
            {
                SocketVoiceServer voiceServer = (SocketVoiceServer)changeData;
                JObject           eventData   = new JObject();
                eventData.Add("token", voiceServer.Token);
                eventData.Add("guild_id", voiceServer.Guild.Id.ToString());
                eventData.Add("endpoint", voiceServer.Endpoint);

                JObject data = new JObject();
                data.Add("op", "voiceUpdate");
                data.Add("guildId", voiceServer.Guild.Id.ToString());
                data.Add("sessionId", sessionId);
                data.Add("event", eventData);

                await manager.GetWebSocket().SendAsync(data.ToString());

                break;
            }

            case SessionChange.Disconnect:
            {
                ulong guildId = (ulong)changeData;

                JObject data = new JObject();
                data.Add("op", "destroy");
                data.Add("guildId", guildId.ToString());

                await manager.GetWebSocket().SendAsync(data.ToString());

                break;
            }

            default:
            {
                Console.WriteLine(new LogMessage(LogSeverity.Debug, "Lavalink", $"Warning: Unknown SessionChange ({change.ToString()})"));

                break;
            }
            }
        }
Beispiel #8
0
        private Task OnVoiceServerUpdated(SocketVoiceServer voiceServer)
        {
            var args = new VoiceServer(voiceServer.Guild.Id, voiceServer.Token, voiceServer.Endpoint);

            return(VoiceServerUpdated.InvokeAsync(this, args));
        }
Beispiel #9
0
 internal VoiceServerUpdate(SocketVoiceServer server)
 {
     Token    = server.Token;
     Endpoint = server.Endpoint;
     GuildId  = $"{server.Guild.Id}";
 }
Beispiel #10
0
        private Task Discord_VoiceServerUpdated(SocketVoiceServer server)
        {
            logger.LogInformation("Voice server updated to {endpoint}", server.Endpoint);

            return(Task.CompletedTask);
        }
 /// <summary>
 /// Detaches and stores the handler for when the bot connects to a or changes Discord voice server.
 /// </summary>
 /// <param name="voiceServer">The new server.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 private Task OnVoiceServerUpdated(SocketVoiceServer voiceServer)
 {
     this.RunningEvents.Enqueue(VoiceServerUpdated(voiceServer));
     return(Task.CompletedTask);
 }
 /// <summary>
 /// Raised when the bot connects to a or changes Discord voice server.
 /// </summary>
 /// <param name="voiceServer">The new server.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 protected virtual Task VoiceServerUpdated([NotNull] SocketVoiceServer voiceServer)
 {
     return(Task.CompletedTask);
 }
Beispiel #13
0
 public VoiceServerPayload(SocketVoiceServer server, string voiceSessionId)
     : base(server.Guild.Id, "voiceUpdate")
 {
     this.SessionId         = voiceSessionId;
     this.VoiceServerUpdate = new VoiceServerUpdate(server);
 }
        public VoiceGatewayClient Create(SocketVoiceServer voiceServer, string sessionId)
        {
            var connectionInfo = new ConnectionInfo(voiceServer, _client.CurrentUser.Id, sessionId);

            return(new(connectionInfo, _cts));
        }
 private Task DiscordSocketClient_VoiceServerUpdated(SocketVoiceServer arg)
 {
     Log("Voice server updated " + arg?.Guild.Value?.Name);
     return(Task.CompletedTask);
 }
Beispiel #16
0
 public VoicePayload(SocketVoiceServer server, SocketVoiceState state)
     : base("voiceUpdate", server.Guild.Id)
 {
     SessionId         = state.VoiceSessionId;
     VoiceServerUpdate = new VoiceServerUpdate(server);
 }
Beispiel #17
0
 public VoiceServerUpdate(SocketVoiceServer server)
 {
     this.Token    = server.Token;
     this.Endpoint = server.Endpoint;
     this.GuildId  = $"{server.Guild.Id}";
 }
 private Task Client_VoiceServerUpdated(SocketVoiceServer arg)
 {
     return(Task.CompletedTask);
 }