コード例 #1
0
        public static async Task <Mee6Server> GetServerAsync(long guildID)
        {
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(Url + $"{guildID}?limit={Limit}");

            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();

            Mee6Server server = JsonConvert.DeserializeObject <Mee6Server>(responseBody);

            return(server);
        }
コード例 #2
0
        public static Mee6Server GetServer(long guildID, string fileName)
        {
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = client.GetAsync(Url + $"{guildID}?limit={Limit}").Result;

            response.EnsureSuccessStatusCode();
            string responseBody = response.Content.ReadAsStringAsync().Result;

            Mee6Server server = JsonConvert.DeserializeObject <Mee6Server>(responseBody);
            string     json   = JsonConvert.SerializeObject(server, Formatting.Indented);

            File.WriteAllText(fileName, json);
            return(server);
        }
コード例 #3
0
        public static Mee6UserInfo GetUserInfo(long guildID, long userID)
        {
            Mee6Server server = GetServer(guildID);

            for (int i = 0; i < Limit; i++)
            {
                Mee6UserInfo user = server.Users[i];
                if (user.Id.Equals(userID.ToString()))
                {
                    return(user);
                }
            }
            return(new Mee6UserInfo());
        }