public async Task RunKinkWizardAsync() { var wizard = new KinkWizard ( _feedback, _kinks, this.Context.User ); await _interactivity.SendPrivateInteractiveMessageAsync(this.Context, _feedback, wizard); }
public async Task <RuntimeResult> RunKinkWizardAsync() { var wizard = new KinkWizard ( _feedback, _interactivity, _kinks, this.Context.User ); await _interactivity.SendPrivateInteractiveMessageAsync(this.Context, _feedback, wizard); return(RuntimeCommandResult.FromSuccess()); }
public async Task <Result> RunKinkWizardAsync() { var categories = await _kinks.GetKinkCategoriesAsync(this.CancellationToken); var initialWizard = new KinkWizard ( _context.User.ID, categories.ToList(), _context is InteractionContext ); var getInitialEmbed = await initialWizard.GetCurrentPageAsync(_kinks, this.CancellationToken); if (!getInitialEmbed.IsDefined(out var initialEmbed)) { return((Result)getInitialEmbed); } var initialComponents = initialWizard.GetCurrentPageComponents(); var send = await _feedback.SendContextualEmbedAsync ( initialEmbed, new FeedbackMessageOptions(MessageComponents : new(initialComponents)), ct : this.CancellationToken ); if (!send.IsSuccess) { return((Result)send); } var messageID = send.Entity.ID; return(_dataService.TryAddData(messageID, initialWizard) ? Result.FromSuccess() : new InvalidOperationError("Failed to add the in-memory data for the kink wizard. Bug?")); }
/// <summary> /// Updates the contents of the wizard. /// </summary> /// <param name="data">The wizard's state.</param> /// <returns>A result which may or may not have succeeded.</returns> private async Task <Result> UpdateAsync ( KinkWizard data ) { var getPage = await data.GetCurrentPageAsync(_kinks, this.CancellationToken); if (!getPage.IsSuccess) { return(Result.FromError(getPage)); } var page = getPage.Entity; if (data.WasCreatedWithInteraction) { return((Result)await _interactionAPI.EditOriginalInteractionResponseAsync ( _context.ApplicationID, _context.Token, embeds : new[] { page }, components : new Optional <IReadOnlyList <IMessageComponent>?>(data.GetCurrentPageComponents()), ct : this.CancellationToken )); } var message = _context.Message.Value; return((Result)await _channelAPI.EditMessageAsync ( message.ChannelID, message.ID, embeds : new[] { page }, components : new Optional <IReadOnlyList <IMessageComponent>?>(data.GetCurrentPageComponents()), ct : this.CancellationToken )); }
public async Task RunKinkWizardAsync() { var wizard = new KinkWizard(this.Database, this.Context, this.Feedback, this.Kinks, this.Interactive); await this.Interactive.SendPrivateInteractiveMessageAsync(this.Context, this.Feedback, wizard); }
private async Task <Result> DisplayHelpTextAsync(KinkWizard data) { var eb = new Embed { Colour = Color.MediumPurple }; switch (data.State) { case KinkWizardState.CategorySelection: { var fields = new List <IEmbedField> { new EmbedField ( "Usage", "Use the navigation buttons to scroll through the available categories. Select a " + "category via the dropdown to start setting preferences for the kinks in that category.\n" + "\n" + $"You can quit at any point by pressing {data.Exit.Emoji.Value.Name.Value}." ) }; eb = eb with { Title = "Help: Category selection", Fields = fields }; break; } case KinkWizardState.KinkPreference: { var fields = new List <IEmbedField> { new EmbedField ( "Usage", "Set your preference for this kink by pressing one of the following buttons:" + $"\n{data.Favourite.Emoji.Value.Name.Value} : Favourite" + $"\n{data.Like.Emoji.Value.Name.Value} : Like" + $"\n{data.Maybe.Emoji.Value.Name.Value} : Maybe" + $"\n{data.No.Emoji.Value.Name.Value} : Never" + $"\n{data.NoPreference.Emoji.Value.Name.Value} : No preference\n" + "\n" + $"\nPress {data.Back.Emoji.Value.Name.Value} to go back to the categories." + $"\nYou can quit at any point by pressing {data.Exit.Emoji.Value.Name.Value}." ) }; eb = eb with { Title = "Help: Kink preference", Fields = fields }; break; } default: { throw new ArgumentOutOfRangeException(nameof(data.State)); } } return((Result)await _feedback.SendContextualEmbedAsync ( eb, new FeedbackMessageOptions(MessageFlags : MessageFlags.Ephemeral), this.CancellationToken )); }