예제 #1
0
        public async Task Logs(params string[] args)
        {
            await p.DoAction(Context.User, Program.Module.Information);

            if (p.GitHubKey == null)
            {
                await ReplyAsync(Base.Sentences.NoApiKey(Context.Guild));

                return;
            }
            dynamic      json;
            EmbedBuilder eb = new EmbedBuilder()
            {
                Title = Sentences.LatestChanges(Context.Guild),
                Color = Color.Green
            };

            using (HttpClient hc = new HttpClient())
            {
                hc.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 Sanara");
                json = JsonConvert.DeserializeObject(await hc.GetStringAsync("https://api.github.com/repos/Xwilarg/Sanara/commits?per_page=5&access_token=" + p.GitHubKey));
            }
            foreach (var j in json)
            {
                eb.AddField(DateTime.ParseExact((string)j.commit.author.date, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).ToString(Base.Sentences.DateHourFormat(Context.Guild))
                            + " " + Sentences.ByStr(Context.Guild) + " " + j.commit.author.name, j.commit.message);
            }
            await ReplyAsync("", false, eb.Build());
        }