Пример #1
0
        public async Task Urban(params string[] words)
        {
            Base.Utilities.CheckAvailability(Context.Guild, Program.Module.Linguistic);
            await p.DoAction(Context.User, Program.Module.Linguistic);

            var result = await Features.Tools.Linguist.UrbanSearch(!((ITextChannel)Context.Channel).IsNsfw, words);

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

                break;

            case Features.Tools.Error.Urban.ChanNotNSFW:
                await ReplyAsync(Base.Sentences.ChanIsNotNsfw(Context.Guild));

                break;

            case Features.Tools.Error.Urban.NotFound:
                await ReplyAsync(Sentences.UrbanNotFound(Context.Guild));

                break;

            case Features.Tools.Error.Urban.None:
                EmbedBuilder em = new EmbedBuilder
                {
                    Color  = Color.Blue,
                    Title  = char.ToUpper(result.answer.word[0]) + string.Concat(result.answer.word.Skip(1)),
                    Fields = new List <EmbedFieldBuilder>()
                    {
                        new EmbedFieldBuilder()
                        {
                            Name  = Sentences.Definition(Context.Guild),
                            Value = result.answer.definition
                        }
                    },
                    Footer = new EmbedFooterBuilder()
                    {
                        Text = Base.Sentences.FromStr(Context.Guild, result.answer.link)
                    }
                };
                if (result.answer.example != "")
                {
                    em.AddField(Sentences.Example(Context.Guild), result.answer.example);
                }
                await ReplyAsync("", false, em.Build());

                break;

            default:
                throw new NotImplementedException();
            }
        }