示例#1
0
        public Embed MakeEmbed()
        {
            int          voteCount = serverData.UserVoteLimit;//MoviesData.Model.GetVoteCount(associatedGuild);
            EmbedBuilder builder   = new EmbedBuilder()
                                     .WithTitle(((showWatched) ? "Watched" : "Suggested") + "Movie Information")
                                     .WithDescription($"Look at all the movies that have been " + ((showWatched)? "watched" : "suggested") + "!")
                                     .WithColor(new Color(0xE314C7))
                                     .WithTimestamp(DateTime.Now)
                                     .WithAuthor(author => {
                author
                .WithName("Movie Night Bot");
            });
            IEnumerable <Movie> movs;

            if (showWatched)
            {
                movs = from m in serverData.GetWatchedMovies() select m;
            }
            else
            {
                //movs = from m in serverData.GetSuggestedMovies() select m;
                //IEnumerable<float> scores = from suggestion in serverData.GetSuggestedMovies()
                //                            where suggestion.Watched == false
                //                            select suggestion.ClassificationScore;
                //float max = scores.Max();

                ////Order the list based on the scoring system.
                //movs = from suggestion in serverData.GetSuggestedMovies()
                //                           where suggestion.Watched == false
                //                           orderby ( ( suggestion.ClassificationScore == -1 ) ? max : suggestion.ClassificationScore )//score
                //                           select suggestion;
                movs = from suggestion in serverData.GetSuggestedMovies()
                       where suggestion.Watched == false
                       orderby suggestion.Title
                       select suggestion;
            }

            movs = movs.Skip(pageNumber * pageSize);
            movs = movs.Take(pageSize);

            if (showWatched)
            {
                foreach (Movie mov in movs)
                {
                    builder.AddField($"{mov.Title}", $"Watched: {mov.WatchedDate}");
                }
            }
            else
            {
                foreach (Movie mov in movs)
                {
                    builder.AddField($"{mov.Title}", $"**Votes:** {mov.TotalVotes} |**Score:** {mov.TotalScore} |**Times Up for Vote:** {mov.TimesUpForVote}");
                }
            }
            builder.AddField("Use reactions to navigate the pages!", $"Page {(pageNumber + 1)} of {totalPages}");
            return(builder.Build());
        }
示例#2
0
        int timeoutTime = 5;//In minuites

        public ShowMovieSuggestions(SocketGuild guild, ISocketMessageChannel channel, bool showWatched)
        {
            this.channel     = channel;
            this.guild       = guild;
            serverData       = ServerData.Get(guild);
            this.showWatched = showWatched;
            Program.SubscribeToReactionRemoved(Action);
            Program.SubscribeToReactionAdded(Action);
            totalPages = showWatched ? serverData.GetWatchedMovies().Count() : serverData.GetSuggestedMovies().Count();
            totalPages = (int)Math.Ceiling(totalPages / (float)pageSize);
            pageNumber = Math.Min(totalPages - 1, pageNumber);
            AutoResetEvent autoEvent = new AutoResetEvent(false);

            expirationTimer = new Timer(OnExpire, autoEvent, 1000 * 60 * timeoutTime, Timeout.Infinite);
            Program.Instance.OnMoviesListModified += OnMoviesModified;
        }