private async Task <OperationResult> NotifyUserNeedsAffirmation ( AutoroleService autoroles, SocketGuild guild, AutoroleConfiguration autorole, IUser user ) { var getAutoroleConfirmation = await autoroles.GetOrCreateAutoroleConfirmationAsync(autorole, user); if (!getAutoroleConfirmation.IsSuccess) { return(OperationResult.FromError(getAutoroleConfirmation)); } var autoroleConfirmation = getAutoroleConfirmation.Entity; if (autoroleConfirmation.HasNotificationBeenSent) { return(OperationResult.FromSuccess()); } var getSettings = await autoroles.GetOrCreateServerSettingsAsync(guild); if (!getSettings.IsSuccess) { return(OperationResult.FromError(getSettings)); } var settings = getSettings.Entity; var notificationChannelID = settings.AffirmationRequiredNotificationChannelID; if (notificationChannelID is null) { return(OperationResult.FromError("There's no notification channel set.")); } var notificationChannel = guild.GetTextChannel((ulong)notificationChannelID.Value); if (notificationChannel is null) { return(OperationResult.FromError("The notification channel is set, but does not exist.")); } var embed = _feedback.CreateEmbedBase() .WithTitle("Confirmation Required") .WithDescription ( $"{MentionUtils.MentionUser(user.Id)} has met the requirements for the " + $"{MentionUtils.MentionRole((ulong)autorole.DiscordRoleID)} role.\n" + $"\n" + $"Use \"!at affirm {MentionUtils.MentionRole((ulong)autorole.DiscordRoleID)} " + $"{MentionUtils.MentionUser(user.Id)}\" to affirm and give the user the role." ) .WithColor(Color.Green); try { await _feedback.SendEmbedAsync(notificationChannel, embed.Build()); var setResult = await autoroles.SetHasNotificationBeenSentAsync(autoroleConfirmation, true); if (!setResult.IsSuccess) { return(OperationResult.FromError(setResult)); } } catch (HttpException hex) when(hex.WasCausedByMissingPermission()) { return(OperationResult.FromError(hex)); } return(OperationResult.FromSuccess()); }