예제 #1
0
파일: Code.cs 프로젝트: TheIndra55/Sanara
        public async Task IncreaseSize(params string[] args)
        {
            Base.Utilities.CheckAvailability(Context.Guild, Program.Module.Code);
            await Program.p.DoAction(Context.User, Program.Module.Code);

            if (Context.Message.Attachments.Count > 0)
            {
                args = new[] { Context.Message.Attachments.ToArray()[0].Url }
            }
            ;
            var result = await Features.Tools.Code.IncreaseSize(args, Program.p.rand);

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

                break;

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

                break;

            case Features.Tools.Error.IncreaseSize.None:
                await Context.Channel.SendFileAsync(result.answer.path);

                break;

            default:
                throw new NotImplementedException();
            }
        }
    }
예제 #2
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();
            }
        }