Ejemplo n.º 1
0
        public async Task Dog(string masterBreed = "", string subBreed = "")
        {
            var       dogApi       = new DogApi();
            const int columnLength = 20;

            var url = dogApi.Random(masterBreed, subBreed);

            if (url != null)
            {
                await Context.Channel.SendMessageAsync(
                    $"{Context.User.Mention} {url}"
                    ).ConfigureAwait(false);
            }
            else
            {
                await Context.ApplyResultReaction(CommandResult.Failed).ConfigureAwait(false);

                var    breeds = dogApi.GetBreeds();
                string lines  = "";
                for (int i = 0; i < breeds.Count(); i += 3)
                {
                    lines += $"{breeds.ElementAt(i).Key.PadRight(columnLength)}"
                             + $"{(breeds.Count > i + 1 ? breeds.ElementAt(i + 1).Key.PadRight(columnLength) : "")}"
                             + $"{(breeds.Count > i + 2 ? breeds.ElementAt(i + 2).Key : "")}"
                             + "\n"
                    ;
                }
                await Context.EmbedAsync(
                    $"Could not find the specified breed, please use one of the following:\n```Markdown\n{lines}\n```",
                    ContextMessageOption.ReplyWithError
                    ).ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
 public void Init()
 {
     instance = new DogApi();
 }