Esempio n. 1
0
        public SearchView(IReadOnlyCollection <SearchItem> items, TarkovDatabaseClient client)
            : base(new LocalMessage()
                   .WithContent("Multiple results found! Please pick one item from the list:"))
        {
            var selectionComponent = new SelectionViewComponent(async args =>
            {
                this.Menu.Stop();
                this.ClearComponents();

                var response = args.Interaction.SelectedValues.FirstOrDefault().Split("/");
                var itemId   = response[0];
                var kind     = Enum.Parse <ItemKind>(response[1]);

                var item             = await client.GetItemAsync(itemId, kind);
                this.TemplateMessage = new LocalMessage().WithEmbeds(item.ToEmbed());
                await(this.Menu as InteractiveMenu).ApplyChangesAsync();
            });

            foreach (var item in items)
            {
                selectionComponent.Row = 0;
                selectionComponent.Options.Add(
                    new LocalSelectionComponentOption($"{item.ShortName} ({item.Kind.Humanize()})".Truncate(25),
                                                      $"{item.Id}/{item.Kind}")
                    .WithDescription(item.Description.Truncate(50)));
            }

            this.AddComponent(selectionComponent);
        }
Esempio n. 2
0
        private void AddSelectionComponent()
        {
            ClearComponents();
            var pageProvider = (SelectionPageProvider)PageProvider;

            Selection = new SelectionViewComponent(HandleSelection);

            for (var i = 0; i < pageProvider.Pages.Count; i++)
            {
                var page   = pageProvider.Pages[i];
                var option = new LocalSelectionComponentOption(page.SelectionLabel, i.ToString())
                             .WithDescription(page.SelectionDescription)
                             .WithEmoji(page.SelectionEmoji);

                Selection.Options.Add(option);
            }

            AddComponent(Selection);
        }