Exemplo n.º 1
0
        //To-DO
        private PostsUpdateEventArgs _redditService_PostsUpdated(PostsUpdateEventArgs eve)
        {
            IEnumerable <Channel> channels = _channelRepo.GetChannelByType(Models.Domain.ChannelType.approval);

            foreach (Channel chan in channels)
            {
                SocketGuild guild = _client.Guilds.FirstOrDefault(g => g.Id == chan.Guild.GuildID);
                if (guild != null)
                {
                    foreach (Post pos in eve.Added)
                    {
                        var   pos2 = pos.Listing;
                        Embed emb;

                        if (postmediaTypes.Contains(pos2.PostHint))
                        {
                            emb = EmbedService.BuildMediaRedditPost(pos, guild).Build();
                        }
                        else
                        {
                            emb = EmbedService.BuildRedditPost(pos, guild).Build();
                        }

                        ISocketMessageChannel chanel = (ISocketMessageChannel)guild.GetChannel(chan.ChanelID);
                        RestUserMessage       msg    = chanel.SendMessageAsync(embed: emb).Result;
                        msg.AddReactionAsync(check);
                        msg.AddReactionAsync(cross);

                        Message mesg = new Message()
                        {
                            Channel   = chan,
                            ChannelID = chan.ChanelID,
                            MessageID = msg.Id
                        };

                        _messageRepo.AddMessage(mesg);
                        _messages.Add(mesg);
                    }
                }
            }

            return(eve);
        }