Exemplo n.º 1
0
        public async Task RunAsync(CancellationToken tokenSource)
        {
            try
            {
                await _discord.InitializeAsync();

                _discord.Client.Log        += _discordLogger.Log;
                _discord.Client.ShardReady += OnClientReady;
                await _commandHandler.InstallCommandsAsync();

                _joinHandler.InstallJoinHandler();
                await _discord.Client.StartAsync();

                await Task.Delay(-1, tokenSource);
            }
            catch (Exception ex)
            {
                if (_discord.Client != null)
                {
                    await _discord.Client.LogoutAsync();

                    _discord.DisposeOfClient();
                }
                _logger.Log(ex.Message, LogSeverity.SEVERITY_ERROR);
            }

            await Task.Delay(-1);
        }
Exemplo n.º 2
0
        public async Task RunAsync(CancellationToken token)
        {
            try
            {
                await _discord.InitializeAsync();

                await _discord.Client.StartAsync();

                await Task.Delay(-1, token);
            }
            catch (Exception)
            {
                if (_discord.Client != null)
                {
                    await _discord.Client.LogoutAsync();

                    _discord.DisposeOfClient();
                }
            }
        }