コード例 #1
0
        public async Task SearchAsync(CommandContext ctx,
                                      [RemainingText, Description("Query.")] string query)
        {
            WikiSearchResponse res = await WikiService.SearchAsync(query);

            if (res is null || !res.Any())
            {
                await this.InformFailureAsync(ctx, "No results...");

                return;
            }

            await ctx.Client.GetInteractivity().SendPaginatedMessageAsync(ctx.Channel, ctx.User, res.Select(r => new Page(embed:
                                                                                                                          new DiscordEmbedBuilder {
                Title       = r.Title,
                Description = string.IsNullOrWhiteSpace(r.Snippet) ? "No description provided" : r.Snippet,
                Url         = r.Url,
                Color       = this.ModuleColor
            }.WithFooter("Powered by Wikipedia API", WikiService.WikipediaIconUrl)
                                                                                                                          )));
        }