Ejemplo n.º 1
0
        async Task OnProposalReceivedAsync(SocketMessage message)
        {
            var userId = message.Author.Id;

            if (!Config.PhotoUserIds.Contains(userId))
            {
                await message.DeleteAsync();

                return;
            }

            Config.Proposals ??= new List <PhotoMessage>();

            if (Config.Proposals.Any(element => element.UserId == userId))
            {
                await message.DeleteAsync();

                return;
            }

            var proposal = new PhotoMessage
            {
                MessageId = message.Id,
                UserId    = userId,
                Topic     = message.Content,
                ImageUrl  = message.Attachments.ElementAt(0).Url,
            };

            Config.Proposals.Add(proposal);

            Console.WriteLine($"Added new proposal from user {proposal.UserId} with topic {proposal.Topic} and image {proposal.ImageUrl}");

            await message.AddReactionAsync(new Emoji("✅"));

            await message.AddReactionAsync(new Emoji("❌"));

            await message.AddReactionAsync(new Emoji("🚫"));

            await PhotoConfig.SaveAsync();
        }
Ejemplo n.º 2
0
        async Task OnPhotoReceivedAsync(SocketMessage message)
        {
            Config.Photos ??= new List <PhotoMessage>();

            if (Config.Photos.Any(element => element.UserId == message.Author.Id))
            {
                await message.DeleteAsync();

                return;
            }

            var photoMessage = new PhotoMessage
            {
                UserId    = message.Author.Id,
                MessageId = message.Id,
                ImageUrl  = message.Attachments.First().Url,
            };

            Config.Photos.Add(photoMessage);

            await PhotoConfig.SaveAsync();
        }