Ejemplo n.º 1
0
        private async Task ClientReady()
        {
            if (_firstConnect)
            {
                if (!IsDebugMode)
                {
                    InviteLink = $"https://discord.com/oauth2/authorize?client_id={_client.CurrentUser.Id}&scope=bot&permissions={(ulong)Constants.InvitePermissions}";

                    if (string.IsNullOrEmpty(Config.DblApiToken))
                    {
                        await _logService.LogAsync(new LogMessage(LogSeverity.Info, "Stats", "Top.gg API token is empty or not set. Bot server count will not be sent to the API."));
                    }
                    else
                    {
                        _dblApi    = new AuthDiscordBotListApi(_client.CurrentUser.Id, Config.DblApiToken);
                        DblBotPage = $"https://top.gg/bot/{_client.CurrentUser.Id}";
                    }

                    if (string.IsNullOrEmpty(Config.DiscordBotsApiToken))
                    {
                        await _logService.LogAsync(new LogMessage(LogSeverity.Info, "Stats", "DiscordBots API token is empty or not set. Bot server count will not be sent to the API."));
                    }
                    else
                    {
                        _discordBots = new DiscordBotsApi(Config.DiscordBotsApiToken);
                    }

                    await UpdateBotListStatsAsync();
                }
                Uptime        = DateTimeOffset.UtcNow;
                _firstConnect = false;
            }
            await _logService.LogAsync(new LogMessage(LogSeverity.Info, "Bot", $"{_client.CurrentUser.Username} is online!"));
        }
Ejemplo n.º 2
0
        public async Task DiscordBotsAvailableTest(string query)
        {
            // Act
            var result = await DiscordBotsApi.GetBotsAsync(query);

            // Assert
            Assert.NotEmpty(result.Bots);

            // Act
            var bot = await DiscordBotsApi.GetBotAsync(ulong.Parse(result.Bots[0].UserId));

            // Assert
            Assert.NotNull(bot);
        }