private async Task UpdateBotListStatsAsync() { try { if (_dblApi != null && _dblBot == null) { try { _dblBot = await _dblApi.GetMeAsync(); } catch (NullReferenceException) { _dblApi = null; await _logService.LogAsync(new LogMessage(LogSeverity.Warning, "Stats", "Could not get the bot info from DBL API, make sure the bot is listed in DBL and the token is valid")); await _logService.LogAsync(new LogMessage(LogSeverity.Info, "Stats", "Bot server count will not be sent to DBL API.")); } } if (_dblBot != null) { await _dblBot.UpdateStatsAsync(_client.Guilds.Count); } if (_discordBots != null) { await _discordBots.UpdateStatsAsync(_client.CurrentUser.Id, _client.Guilds.Count); } } catch (Exception e) when(e is HttpRequestException || e is TaskCanceledException) { await _logService.LogAsync(new LogMessage(LogSeverity.Warning, "Stats", "Could not update the DBL/DiscordBots bot stats", e)); } }
private async Task <(bool, int)> UpdateBotWebsitesAsync() { int serverCount = this.DiscordClient.Guilds.Count; bool success = true; if (this.IsDevEnv) { return(true, serverCount); } try { var obj = new { guildCount = serverCount }; if (JsonHelper.TrySerialize(obj, this.Logger, out string json)) { string endpoint = $"https://discord.bots.gg/api/v1/bots/{Config.Instance.Discord.BotID}/stats"; await HttpHelper.PostAsync(endpoint, json, this.Logger, null, req => { req.Headers[System.Net.HttpRequestHeader.Authorization] = Config.Instance.Discord.BotsToken; req.ContentType = "application/json"; }); } IDblSelfBot me = await this.DiscordBotList.GetMeAsync(); await me.UpdateStatsAsync(serverCount); } catch { success = false; } return(success, serverCount); }
// Update the server count private async Task UpdateServerCount() { // Update on the bot's status await _client.SetGameAsync($"/rt | {_client.Guilds.Count} servers", type : ActivityType.Watching); // Update on top.gg await _dblApi.UpdateStatsAsync(_client.Guilds.Count); }
private static async Task UpdateTopGGStats() { if (bot.CurrentUser.Id == 729696788097007717) // make sure we are only setting this on the main bot, not test bot! { AuthDiscordBotListApi DblApi = GetTopGGClient(); IDblSelfBot me = await DblApi.GetMeAsync(); await me.UpdateStatsAsync(bot.Guilds.Count); } }
// Update the bot shard and guild count for DiscordBotList public async Task DBLGet() { AuthDiscordBotListApi DblApi = new AuthDiscordBotListApi(Config.bot.selfID, Config.bot.dblToken); IDblSelfBot me = await DblApi.GetMeAsync(); // Update stats sharded indexShard shardCount shards //await me.UpdateStatsAsync(24, 50, new[] { 12, 421, 62, 241, 524, 534 }); // Update stats guildCount await me.UpdateStatsAsync(_client.Guilds.Count); }
public async Task UpdateDBLStatsAsync(int serverCount) { try { IDblSelfBot self = await dblApi.GetMeAsync(); await self.UpdateStatsAsync(serverCount); } catch (Exception e) { await lib.EdgyLog(LogSeverity.Error, e.Message); } }
public async Task UpdateGuildCount(int count) { if (_enabled) { if (me == null) { this.me = await dblapi.GetMeAsync(); } await me.UpdateStatsAsync(count); } }
public async Task Update() { await Task.Run(async() => { while (true) { #if !DEV await DblSelfBot.UpdateStatsAsync(Discord.Guilds.Count); #endif await Discord.UpdateStatusAsync(new DiscordActivity( $"for messages in {Discord.Guilds.Count} servers | prefix w+ ", ActivityType.Watching)); await Task.Delay(3600000); } // ReSharper disable once FunctionNeverReturns }); }
public async Task OnReady() { var botID = ulong.TryParse(Config.bot.BotUserID, out ulong ID); var mutualGuilds = _client.GetUser(ID).MutualGuilds; AuthDiscordBotListApi dblAPI = new AuthDiscordBotListApi(ID, Config.bot.DblApiKey); Console.WriteLine("\nRetrieving bot from DBL API..."); IDblSelfBot me = await dblAPI.GetMeAsync(); Console.WriteLine("Pushing stats to DBL API..."); await me.UpdateStatsAsync(mutualGuilds.Count()); Console.WriteLine("Success."); var serverCountValue = new Dictionary <string, string> { { "server_count", $"{mutualGuilds.Count()}" } }; int i = 0; foreach (var guild in mutualGuilds) { for (int j = 0; j <= guild.MemberCount; j++) { i++; } } Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"\nAce Pilot Kaguya cleared for takeoff. Servicing {mutualGuilds.Count()} guilds" + $" and {i.ToString("N0")} members." + "\nBegin Logging\n"); Console.WriteLine("--------------------------------------------"); }