/// <summary>
        /// Asynchronously retrieves a bot specified by their unique identifier (nullable).
        /// </summary>
        /// <typeparam name="T">Represents the object type that this bot will be returned as.</typeparam>
        /// <param name="id">The unique identifier of the bot that you wish to retrieve.</param>
        /// <returns>A <see cref="T"/> instance from the specified unique identifier.</returns>
        internal async Task <T> GetBotAsync <T>(ulong id)
            where T : DblBot
        {
            var t = await GetAsync <T>(DblApi.GetBotEndpoint(id));

            t.Client = this;
            return(t);
        }
        /// <summary>
        /// Asynchronously retrieves a list of all bots on a specified search.
        /// </summary>
        /// <param name="searchParams">The search parameters to use for this request.</param>
        /// <returns>A list of bots from the specified search.</returns>
        public async Task <ISearchResult <IDblBot> > GetBotsAsync(BotSearchParams searchParams)
        {
            searchParams = searchParams ?? new BotSearchParams
            {
                Limit  = BotSearchParams.DefaultLimit,
                Offset = BotSearchParams.DefaultOffset
            };

            var result = await GetAsync <BotSearchResult>(DblApi.GetSearchEndpoint(searchParams));

            foreach (DblBot bot in result.Values)
            {
                bot.Client = this;
            }

            return(result);
        }
示例#3
0
 protected async Task <bool> GetUserVoteAsync(ulong userId)
 => (await GetAsync <VoteResult>(DblApi.GetVoteCheckEndpoint(CurrentUserId, userId))).Voted;
示例#4
0
 protected async Task UpdateStatsInternalAsync(object stats)
 {
     string json    = JsonConvert.SerializeObject(stats, _statSettings);
     var    content = new StringContent(json, Encoding.UTF8, "application/json");
     await HttpClient.PostAsync($"{DblApi.BaseUrl}{DblApi.GetStatsEndpoint(CurrentUserId)}", content);
 }
示例#5
0
 protected async Task <List <T> > GetVotersAsync <T>()
 => await GetAuthorizedAsync <List <T> >(DblApi.GetVotesEndpoint(CurrentUserId));
 /// <summary>
 /// Asynchronously retrieves the user specified by their unique identifier (nullable).
 /// </summary>
 /// <param name="id">The unique identifier of the user you wish to retrieve.</param>
 /// <returns>A generic <see cref="IDblUser"/> object.</returns>
 public async Task <IDblUser> GetUserAsync(ulong id)
 => await GetAsync <DblUser>(DblApi.GetUserEndpoint(id));
 /// <summary>
 /// Asynchronously retrieves the stats of a bot specified by its unique identifier (nullable).
 /// </summary>
 /// <param name="id">The unique identifier of the bot you wish to retrieve stats for.</param>
 /// <returns>A generic <see cref="IDblBotStats"/> object.</returns>
 public async Task <IDblBotStats> GetBotStatsAsync(ulong id)
 => await GetAsync <DblBotStats>(DblApi.GetStatsEndpoint(id));