示例#1
0
        public async Task FAQ([Remainder] string Question = "null")
        {
            Dictionary <string, string> _FAQ;
            string _FAQJson = BotUtils.GetJsonFromFile("Json/FAQ.json").ToString();
            var    _Data    = BotUtils.GetDataFromJson(_FAQJson);

            _FAQ = _Data.ToObject <Dictionary <string, string> >();

            string _Answer = "";

            string _NewQuestion = Question.ToLower();
            string _FirstLetter = Question[0].ToString().ToUpper();

            if (Question.Length > 1 && !Question.Contains(" "))
            {
                _NewQuestion = _FirstLetter + Question.Remove(0, 1);
            }
            else if (Question.Length > 1 && Question.Contains(" "))
            {
                string[] _SubStrings   = _NewQuestion.Split(' ');
                string   _SubTwo       = _SubStrings[1];
                string   _SecondLetter = _SubTwo[0].ToString().ToUpper();
                _NewQuestion = _FirstLetter + _SubStrings[0].Remove(0, 1) + " " + _SecondLetter + _SubStrings[1].Remove(0, 1);
            }

            if (_FAQ.ContainsKey(_NewQuestion))
            {
                _FAQ.TryGetValue(_NewQuestion, out _Answer);
            }
            else
            {
                _Answer = "List of Valid Questions: \n";
                for (int Index = 0; Index < _FAQ.Count; ++Index)
                {
                    _Answer += _FAQ.Keys.ElementAt(Index) + "\n";
                }
            }

            var _Embed = new EmbedBuilder();

            _Embed.WithTitle("FAQ:");
            _Embed.WithColor(0, 255, 0);
            _Embed.WithDescription(_Answer);
            await Context.Channel.SendMessageAsync("", false, _Embed);
        }