Exemple #1
0
        public ValueListMessage(string keyword, List <KeywordValue> values, Func <Task> galleryButton, int?page = null)
            : base(new List <EmbedFieldBuilder>(), $"*There are {values.Count} values in total, as listed below.*", $"📒 Values for '{keyword}'", page)
        {
            foreach (KeywordValue value in values)
            {
                var user = value.AddedByUserId == 0 ?
                           "[UNKNOWN USER]" : BotService.Client.GetUser(value.AddedByUserId).Username;
                var date = value.DateTimeAddedBinary == 0 ?
                           "[UNKNOWN DATE]" : DateTime.FromBinary(value.DateTimeAddedBinary).ToDiscordTimestamp("D");

                AllFieldBuilders.Add(
                    new EmbedFieldBuilder()
                {
                    Name  = $"Added by {user} at {date}",
                    Value = $"{value.TimesLiked} times liked, {value.TimesDeleted} times deleted.\n```{value.Content}```",
                });
            }

            GalleryButton = galleryButton;
        }
Exemple #2
0
        public ListOfSongsMessage(Queue <UserSongRequest> queue, string title = "List of songs", int?page = null)
            : base(new List <EmbedFieldBuilder>(), $"*The total duration of the songs below is {VoiceModule.DurationAsString(queue.Sum(r => r.VideoMetadata.Duration))}*", title)
        {
            double totalDuration = 0;
            int    i             = 0;

            foreach (UserSongRequest songRequest in queue)
            {
                i++;
                totalDuration += songRequest.VideoMetadata.Duration;
                var fieldBuilderForSongRequest = new EmbedFieldBuilder()
                {
                    Name  = $"{i}) {songRequest.VideoMetadata.Title}",
                    Value = $"[More details]({songRequest.VideoMetadata.WebpageUrl}) • {VoiceModule.DurationAsString(songRequest.VideoMetadata.Duration)} \nRequested {songRequest.TimeRequested.ToDiscordTimestamp("R")} by {songRequest.RequestedByMention}",
                };
                AllFieldBuilders.Add(fieldBuilderForSongRequest);
            }

            Page = page;
            UpdateProperties();
        }
Exemple #3
0
        protected LeaderboardMessage(
            IEnumerable <LeaderboardEntry> leaderboardEntries,
            Func <LeaderboardEntry, string> detailsPredicate,
            string title,
            string description = null,
            int?page           = null)
            : base(new List <EmbedFieldBuilder>(), description, title)
        {
            int num = 1;

            foreach (var entry in leaderboardEntries)
            {
                AllFieldBuilders.Add(new EmbedFieldBuilder()
                {
                    Name  = $"{num}) {entry.Points} points",
                    Value = $"{entry.PlayedByMention} at {entry.PlayedAt.ToDiscordTimestamp("f")}\n{detailsPredicate.Invoke(entry)}",
                });
                num++;
            }

            Page = page;
            UpdateProperties();
        }