Esempio n. 1
0
        public async Task Define([Remainder] string word)
        {
            OxfordDictionaryClient client = new OxfordDictionaryClient("45278ea9", "c4dcdf7c03df65ac5791b67874d956ce");
            var result = await client.SearchEntries(word, CancellationToken.None);

            if (result != null)
            {
                var senses = result.Results[0].LexicalEntries[0].Entries[0].Senses[0];

                JEmbed emb = new JEmbed();
                emb.Title       = Func.ToTitleCase(word);
                emb.Description = Char.ToUpper(senses.Definitions[0][0]) + senses.Definitions[0].Substring(1) + ".";
                emb.ColorStripe = Constants.Colours.YORK_RED;
                if (senses.Examples != null)
                {
                    emb.Fields.Add(new JEmbedField(x =>
                    {
                        x.Header    = "Examples:";
                        string text = "";
                        foreach (OxfordDictionariesAPI.Models.Example eg in senses.Examples)
                        {
                            text += $"\"{Char.ToUpper(eg.Text[0]) + eg.Text.Substring(1)}.\"\n";
                        }
                        x.Text = text;
                    }));
                }
                await Context.Channel.SendMessageAsync("", embed : emb.Build());
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Could not find definition for: {word}.");
            }
        }
Esempio n. 2
0
 public HomeController(ILogger <HomeController> logger, CovidClient covidClient, NasaClient nasaClient, SpaceXClient spaceXClient, OxfordDictionaryClient oxfordDictionaryClient)
 {
     _logger                 = logger;
     _covidClient            = covidClient;
     _nasaClient             = nasaClient;
     _spaceXClient           = spaceXClient;
     _oxfordDictionaryClient = oxfordDictionaryClient;
 }
Esempio n. 3
0
 /// <inheritdoc />
 public DictionaryService()
 {
     OxfordDictClient = new OxfordDictionaryClient();
     MustacheEngine   = CreateStubbleVisitor();
 }