Beispiel #1
0
        public async Task <IActionResult> CreatePendingApplication(PendingApplicationViewModel pendingApplicationViewModel)
        {
            var userId        = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var developer     = _context.Developers.FirstOrDefault(a => a.UserId == userId);
            var roleOpeningId = pendingApplicationViewModel.Opening.Id;
            PendingApplication pendingApplication = new PendingApplication();

            pendingApplication.OpeningId   = roleOpeningId;
            pendingApplication.DeveloperId = developer.Id;
            pendingApplication.Email       = pendingApplicationViewModel.PendingApplication.Email;
            _context.PendingApplications.Add(pendingApplication);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #2
0
        private static async void AddInteractivity(PendingApplication application)
        {
            var applicationEmbed = new DiscordEmbedBuilder
            {
                Title        = application.Title,
                Description  = application.ApplicantRespones,
                ThumbnailUrl = application.Applicant.AvatarUrl,
                Color        = DiscordColor.Yellow
            };

            var thumbsUpEmoji   = DiscordEmoji.FromName(Bot.Client, ":+1:");
            var thumbsDownEmoji = DiscordEmoji.FromName(Bot.Client, ":-1:");

            var interactivity  = Bot.Client.GetInteractivityModule();
            var reactionResult = await interactivity.WaitForMessageReactionAsync(
                x => x.Name == thumbsUpEmoji ||
                x.Name == thumbsDownEmoji,
                application.Message).ConfigureAwait(false);

            var role = application.Message.Channel.Guild.GetRole(TEST_ROLE);

            if (reactionResult.Emoji == thumbsUpEmoji)
            {
                await application.Applicant.GrantRoleAsync(role).ConfigureAwait(false);

                await application.Applicant.SendMessageAsync("Your application for " + applicationEmbed.Title + " has been aprooved").ConfigureAwait(false);

                applicationEmbed.Color = DiscordColor.Green;
            }
            else if (reactionResult.Emoji == thumbsDownEmoji)
            {
                await application.Applicant.SendMessageAsync("Your application for " + applicationEmbed.Title + " has been denied").ConfigureAwait(false);

                applicationEmbed.Color = DiscordColor.Red;
            }

            applicationEmbed.Description = reactionResult.User.Username + " has aprooved this application:" + Environment.NewLine + applicationEmbed.Description;
            await application.Message.Channel.Guild.GetChannel(id : FINISHED_APPLICATION_CHANEL).SendMessageAsync(embed: applicationEmbed).ConfigureAwait(false);

            await Task.Delay(200);

            var chanel = application.Message.Channel.Guild.GetChannel(PENDING_RESPONSES_CHANNEL);
            await chanel.DeleteMessageAsync(application.Message).ConfigureAwait(false);

            pendingApplications.Remove(application);
        }
Beispiel #3
0
        static async Task LoadApplications()
        {
            Console.WriteLine("Loading Application Forms");
            Dictionary <string, object> loadedApplications = SavingSystem.Load(APPLICATIONS);

            foreach (object application in loadedApplications.Values)
            {
                Application loadedApplication = new Application("_LoadedApplication_");
                await loadedApplication.RestoreState(application).ConfigureAwait(false);

                applications.Add(loadedApplication);
                Log("Application " + loadedApplication.Title + " : Loaded", ConsoleColor.Green);
            }


            Console.WriteLine("Loading Finished Applications");
            Dictionary <string, object> loadedFinishedApplications = SavingSystem.Load(FINISHED_APPLICATIONS);

            foreach (object loadedFinishedApplication in loadedFinishedApplications.Values)
            {
                try
                {
                    PendingApplication application = new PendingApplication(null, null, null, loadedFinishedApplication);
                    await application.RestoreState(loadedFinishedApplication).ConfigureAwait(false);

                    Log(
                        "Pending Application " + application.Message.Id +
                        " for " + application.Message.Channel.GuildId +
                        " in " + application.Message.ChannelId + " : Loaded", ConsoleColor.Green);
                    pendingApplications.Add(application);

                    AddInteractivity(application);
                }
                catch
                {
                    Log("Dead application found and skipped", ConsoleColor.Red);
                }
            }
        }
Beispiel #4
0
        public async Task StartApplication(CommandContext ctx, string applicationAppliedFor)
        {
            Application application = null;

            foreach (Application app in applications)
            {
                if (app.Title == applicationAppliedFor)
                {
                    application = app;
                    break;
                }
            }

            if (application == null)
            {
                return;
            }


            int questionsAnswered = 0;
            ApplicationInProgress applicationInProgress = new ApplicationInProgress(ctx, application);

            foreach (Question question in application.Questions)
            {
                await SendQuestion(ctx, question, applicationInProgress).ConfigureAwait(false);

                questionsAnswered++;
            }

            if (questionsAnswered < application.Questions.Count)
            {
                return;
            }

            await ctx.Member.SendMessageAsync("Application Finished").ConfigureAwait(false);

            var applicationEmbed = new DiscordEmbedBuilder
            {
                Title        = applicationInProgress.Title,
                Description  = applicationInProgress.GetApplicationResults(),
                ThumbnailUrl = ctx.Client.CurrentUser.AvatarUrl,
                Color        = DiscordColor.Yellow
            };
            var applicationMessage = await ctx.Guild.GetChannel(id : PENDING_RESPONSES_CHANNEL).SendMessageAsync(embed: applicationEmbed).ConfigureAwait(false);

            // real iffy here
            PendingApplication pendingApplication = new PendingApplication(applicationMessage, ctx.Member, applicationInProgress, applicationEmbed.Description);

            pendingApplications.Add(pendingApplication);

            SaveFinishedApplications();

            // reaction role assignment
            var thumbsUpEmoji   = DiscordEmoji.FromName(ctx.Client, ":+1:");
            var thumbsDownEmoji = DiscordEmoji.FromName(ctx.Client, ":-1:");

            DiscordEmoji[] emojis = new DiscordEmoji[2] {
                thumbsUpEmoji, thumbsDownEmoji
            };

            await AddReactions(applicationMessage, emojis).ConfigureAwait(false);

            // I don't actualy know
            AddInteractivity(pendingApplication);


            //// actual reaction interactivity for application confirmation
            //var interactivity = ctx.Client.GetInteractivityModule();
            //var reactionResult = await interactivity.WaitForMessageReactionAsync(
            //x => x.Name == thumbsUpEmoji ||
            //x.Name == thumbsDownEmoji,
            //applicationMessage).ConfigureAwait(false);

            //var role = ctx.Guild.GetRole(TEST_ROLE);
            //if (reactionResult.Emoji == thumbsUpEmoji)
            //{
            //    await ctx.Member.GrantRoleAsync(role).ConfigureAwait(false);
            //    await ctx.Member.SendMessageAsync("Your application for " + application.Title + " has been aprooved").ConfigureAwait(false);
            //    applicationEmbed.Color = DiscordColor.Green;
            //}
            //else if (reactionResult.Emoji == thumbsDownEmoji)
            //{
            //    await ctx.Member.SendMessageAsync("Your application for " + application.Title + " has been denied").ConfigureAwait(false);
            //    applicationEmbed.Color = DiscordColor.Red;
            //}

            //applicationEmbed.Description = reactionResult.User.Username + " has aprooved this application:" + Environment.NewLine + applicationEmbed.Description;
            //await ctx.Guild.GetChannel(id: FINISHED_APPLICATION_CHANEL).SendMessageAsync(embed: applicationEmbed).ConfigureAwait(false);
            //await Task.Delay(200);
            //var chanel = ctx.Guild.GetChannel(PENDING_RESPONSES_CHANNEL);
            //await chanel.DeleteMessageAsync(applicationMessage).ConfigureAwait(false);
        }