Ejemplo n.º 1
0
        public async Task Translation(params string[] words)
        {
            Base.Utilities.CheckAvailability(Context.Guild, Program.Module.Linguistic);
            await p.DoAction(Context.User, Program.Module.Linguistic);

            if (Context.Message.Attachments.Count > 0)
            {
                var list = words.ToList();
                list.Add(Context.Message.Attachments.ToArray()[0].Url);
                words = list.ToArray();
            }
            var result = await Features.Tools.Linguist.Translate(words, Program.p.translationClient, Program.p.visionClient, Program.p.allLanguages);

            switch (result.error)
            {
            case Features.Tools.Error.Translation.Help:
                await ReplyAsync(Sentences.TranslateHelp(Context.Guild));

                break;

            case Features.Tools.Error.Translation.InvalidApiKey:
                await ReplyAsync(Base.Sentences.NoApiKey(Context.Guild));

                break;

            case Features.Tools.Error.Translation.InvalidLanguage:
                await ReplyAsync(Sentences.InvalidLanguage(Context.Guild));

                break;

            case Features.Tools.Error.Translation.NotAnImage:
                await ReplyAsync(Sentences.NotAnImage(Context.Guild));

                break;

            case Features.Tools.Error.Translation.NoTextOnImage:
                await ReplyAsync(Sentences.NoTextOnImage(Context.Guild));

                break;

            case Features.Tools.Error.Translation.None:
                await ReplyAsync("", false, new EmbedBuilder()
                {
                    Color       = Color.Blue,
                    Title       = Base.Sentences.FromStr(Context.Guild, result.answer.sourceLanguage),
                    Description = result.answer.sentence
                }.Build());

                break;

            default:
                throw new NotImplementedException();
            }
        }