Exemplo n.º 1
0
        private RestDiscordClient(TokenType?optionalTokenType, string token, RestDiscordClientConfiguration configuration = null)
        {
            ApiClient   = new RestDiscordApiClient(optionalTokenType, token, configuration ?? new RestDiscordClientConfiguration());
            CurrentUser = RestFetchable.Create(this, async(@this, options) =>
            {
                var model = await @this.ApiClient.GetCurrentUserAsync(options).ConfigureAwait(false);
                return(new RestCurrentUser(@this, model));
            });
            CurrentApplication = RestFetchable.Create(this, async(@this, options) =>
            {
                //if (TokenType != TokenType.Bot)
                //    throw new InvalidOperationException("Cannot download the current application without a bot authorization token.");

                var model = await @this.ApiClient.GetCurrentApplicationInformationAsync(options).ConfigureAwait(false);
                return(new RestApplication(@this, model));
            });
        }
Exemplo n.º 2
0
 public RestDiscordClient(TokenType tokenType, string token, RestDiscordClientConfiguration configuration = null)
     : this(optionalTokenType : tokenType, token ?? throw new ArgumentNullException(nameof(token)), configuration)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Initialises a new <see cref="RestDiscordClient"/> without authorization.
 /// </summary>
 public static RestDiscordClient CreateWithoutAuthorization(RestDiscordClientConfiguration configuration = null)
 => new RestDiscordClient(null, null, configuration);