Exemplo n.º 1
0
        public async Task Language(string language = null)
        {
            if (Context.User.Id != Context.Guild.OwnerId)
            {
                await ReplyAsync(Sentences.OnlyUser(Context.Guild.Id, (await Context.Guild.GetOwnerAsync()).ToString()));

                return;
            }
            if (language == null)
            {
                await ReplyAsync(Sentences.LanguageHelp(Context.Guild.Id));

                return;
            }
            string key = null;

            language = language.ToLower();
            var alternate = p.GetTranslationKeyAlternate();

            if (alternate.ContainsKey(language))
            {
                key = language;
            }
            else
            {
                foreach (var k in alternate)
                {
                    if (k.Value.Contains(language))
                    {
                        key = k.Key;
                        break;
                    }
                }
            }
            if (key == null)
            {
                await ReplyAsync(Sentences.InvalidLanguage(Context.Guild.Id));
            }
            else
            {
                await Program.p.GetDb().SetLanguage(Context.Guild.Id, key);

                Program.p.GetLanguages()[Context.Guild.Id] = key;
                await ReplyAsync(Sentences.LanguageChanged(Context.Guild.Id));
            }
        }