Ejemplo n.º 1
0
        protected async Task InitializeAsync(BaseSocketClient baseSocketClient, Configuration configuration)
        {
            this._baseSocketClient = baseSocketClient;
            var shards = baseSocketClient switch
            {
                DiscordSocketClient socketClient
                => await socketClient.GetRecommendedShardCountAsync(),

                DiscordShardedClient shardedClient
                => shardedClient.Shards.Count,

                _ => 1
            };

            this.Configuration       = configuration.SetInternals(baseSocketClient.CurrentUser.Id, shards);
            Players                  = new ConcurrentDictionary <ulong, LavaPlayer>();
            _cancellationTokenSource = new CancellationTokenSource();
            baseSocketClient.UserVoiceStateUpdated += OnUserVoiceStateUpdated;
            baseSocketClient.VoiceServerUpdated    += OnVoiceServerUpdated;

            _socketHelper            = new SocketHelper(configuration, Log);
            _socketHelper.OnMessage += OnMessage;
            _socketHelper.OnClosed  += OnClosedAsync;

            await _socketHelper.ConnectAsync().ConfigureAwait(false);
        }
Ejemplo n.º 2
0
        protected async Task InitializeAsync(BaseSocketClient baseSocketClient, Configuration configuration)
        {
            this.baseSocketClient = baseSocketClient;
            logSeverity           = configuration.LogSeverity.Value;
            _players = new ConcurrentDictionary <ulong, LavaPlayer>();
            baseSocketClient.UserVoiceStateUpdated += OnUserVoiceStateUpdated;
            baseSocketClient.VoiceServerUpdated    += OnVoiceServerUpdated;

            socketHelper            = new SocketHelper(configuration, _log);
            socketHelper.OnMessage += OnMessage;

            await socketHelper.ConnectAsync().ConfigureAwait(false);
        }