Пример #1
0
        internal Embed CreatePollEmbed()
        {
            EmbedBuilder b = new EmbedBuilder();

            b.WithAuthor($"Poll by {PollCreator.Username}#{PollCreator.DiscriminatorValue}", PollCreator.GetAvatarUrl());
            b.WithDescription($"**{PollTitle}**");
            b.WithFooter($"PollID: {PollId}");
            b.WithColor(0, 255, 0);
            float total = PollReactions.Count;

            foreach (PollOption s in PollOptions)
            {
                float amt = PollReactions.Count(x => x.PollVote == s.Option);
                if (total == 0)
                {
                    b.AddField($"{s.React} {s.Option}", $"{GetPercentageBar(this, s.Option)} - {amt}/{total} (0,00%)");
                }
                else
                {
                    b.AddField($"{s.React} {s.Option}", $"{GetPercentageBar(this, s.Option)} - {amt}/{total} ({(amt / total * 100).ToString("N2")}%)");
                }
            }

            return(b.Build());
        }
Пример #2
0
 internal bool?AddReaction(SocketUser usr, string vote)
 {
     if (PollOptions.Where(x => x.Option == vote) == null)
     {
         return(null);
     }
     if (PollReactions.Where(x => x.User.Id == usr.Id) == null)
     {
         return(false);
     }
     PollReactions.Add(new PollReaction(usr, vote));
     return(true);
 }
Пример #3
0
 internal bool?RemoveReaction(SocketUser usr, string vote)
 {
     if (PollOptions.Where(x => x.Option == vote) == null)
     {
         return(null);
     }
     if (PollReactions.Where(x => x.User.Id == usr.Id) == null)
     {
         return(false);
     }
     PollReactions.Remove(PollReactions.Single(x => x.User.Id == usr.Id && x.PollVote == vote));
     return(true);
 }
            public void Insert(Guid ReactionId, Guid UserId, DateTime CreationDate, string Reaction, Guid PollId)
            {
                PollReactions item = new PollReactions();

                item.ReactionId = ReactionId;

                item.UserId = UserId;

                item.CreationDate = CreationDate;

                item.Reaction = Reaction;

                item.PollId = PollId;

                item.Save(UserName);
            }