コード例 #1
0
ファイル: TriviaModule.cs プロジェクト: MarkusKgit/MonkeyBot
        public async Task GetScoresAsync(CommandContext ctx, [Description("The amount of scores to get.")] int amount = 5)
        {
            List <(ulong UserId, int Score)> globalScores = (await _triviaService.GetGlobalHighScoresAsync(ctx.Guild.Id, amount)).ToList();

            if (globalScores != null && globalScores.Any())
            {
                List <string> scores = new List <string>();
                for (int i = 0; i < globalScores.Count; i++)
                {
                    var           score  = globalScores[i];
                    DiscordMember member = await ctx.Guild.GetMemberAsync(score.UserId);

                    scores.Add(Formatter.Bold($"#{i + 1} ") + (member?.DisplayName ?? "Invalid User") + $": {score.Score} points");
                }

                var embedBuilder = new DiscordEmbedBuilder()
                                   .WithColor(new DiscordColor(46, 191, 84))
                                   .WithTitle("Trivia high scores")
                                   .WithDescription(string.Join("\n", scores));
                await ctx.RespondAsync("", embed : embedBuilder.Build());
            }
            else
            {
                await ctx.ErrorAsync("No stored scores found!");
            }
        }
コード例 #2
0
ファイル: TriviaModule.cs プロジェクト: randianb/MonkeyBot
        public async Task GetScoresAsync([Summary("The amount of scores to get.")] int amount = 5)
        {
            var globalScores = await triviaService.GetGlobalHighScoresAsync(amount, Context as SocketCommandContext).ConfigureAwait(false);

            if (globalScores != null)
            {
                var embedBuilder = new EmbedBuilder()
                                   .WithColor(new Color(46, 191, 84))
                                   .WithTitle("Global scores")
                                   .WithDescription(globalScores);
                await ReplyAsync("", embed : embedBuilder.Build()).ConfigureAwait(false);
            }
            else
            {
                await ReplyAsync("No stored scores found!").ConfigureAwait(false);
            }
        }