private async Task DiscordShardedClientOnVoiceServerUpdated(SocketVoiceServer arg)
 {
     if (VoiceServerUpdated != null)
     {
         await VoiceServerUpdated(this, arg).ConfigureAwait(false);
     }
 }
コード例 #2
0
 public ConnectionInfo(SocketVoiceServer voiceServer, ulong userId, string sessionId)
 {
     GuildId   = voiceServer.Guild.Id;
     UserId    = userId;
     Token     = voiceServer.Token;
     Endpoint  = voiceServer.Endpoint;
     SessionId = sessionId;
 }
コード例 #3
0
 private async Task VoiceServerUpdate(SocketVoiceServer voiceServer)
 {
     await Lavalink.VoiceServerUpdateAsync(new VoiceServerUpdate {
         Endpoint = voiceServer.Endpoint,
         GuildID  = voiceServer.Guild.Id,
         Token    = voiceServer.Token
     });
 }
コード例 #4
0
ファイル: LavaBaseClient.cs プロジェクト: N0tAI/Energize
        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));
        }
コード例 #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);
        }
コード例 #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;
            }
            }
        }
コード例 #7
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;
            }

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

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

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

            return(Task.CompletedTask);
        }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
 /// <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);
 }
コード例 #13
0
 public VoiceServerPayload(SocketVoiceServer server, string voiceSessionId)
     : base(server.Guild.Id, "voiceUpdate")
 {
     this.SessionId         = voiceSessionId;
     this.VoiceServerUpdate = new VoiceServerUpdate(server);
 }
コード例 #14
0
        public VoiceGatewayClient Create(SocketVoiceServer voiceServer, string sessionId)
        {
            var connectionInfo = new ConnectionInfo(voiceServer, _client.CurrentUser.Id, sessionId);

            return(new(connectionInfo, _cts));
        }
コード例 #15
0
 private Task DiscordSocketClient_VoiceServerUpdated(SocketVoiceServer arg)
 {
     Log("Voice server updated " + arg?.Guild.Value?.Name);
     return(Task.CompletedTask);
 }
コード例 #16
0
 public VoicePayload(SocketVoiceServer server, SocketVoiceState state)
     : base("voiceUpdate", server.Guild.Id)
 {
     SessionId         = state.VoiceSessionId;
     VoiceServerUpdate = new VoiceServerUpdate(server);
 }
コード例 #17
0
ファイル: VoiceServerUpdate.cs プロジェクト: N0tAI/Energize
 public VoiceServerUpdate(SocketVoiceServer server)
 {
     this.Token    = server.Token;
     this.Endpoint = server.Endpoint;
     this.GuildId  = $"{server.Guild.Id}";
 }
コード例 #18
0
 private Task Client_VoiceServerUpdated(SocketVoiceServer arg)
 {
     return(Task.CompletedTask);
 }