コード例 #1
0
        public TeamInformation CreateTeamAndGetInformation(string Team_Name)
        {
            var Req = (HttpWebRequest)WebRequest.Create($"https://discord.com/api/v6/teams");

            var postData = "{" + $"\"name\":\"{Team_Name}\"" + "}";

            var    data      = Encoding.ASCII.GetBytes(postData);
            string UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36";

            Req.Method      = "POST";
            Req.UserAgent   = UserAgent;
            Req.ContentType = "application/json";
            Req.Headers.Add("authorization", Token);
            Req.ContentLength = data.Length;

            using (var stream = Req.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            var response       = (HttpWebResponse)Req.GetResponse();
            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

            TeamInformation team = Newtonsoft.Json.JsonConvert.DeserializeObject <TeamInformation>(responseString);

            return(team);
        }
コード例 #2
0
        public TeamMembers GetTeamMembers(TeamInformation Team)
        {
            var Req = (HttpWebRequest)WebRequest.Create($"https://discord.com/api/v6/teams/" + Team.id.ToString() + "/members");

            Req.Method      = "GET";
            Req.ContentType = "application/json";
            Req.Headers.Add("authorization", Token);
            var         response       = (HttpWebResponse)Req.GetResponse();
            var         responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
            string      raw            = "{*TeamMember*:";
            TeamMembers team           = JsonConvert.DeserializeObject <TeamMembers>(raw.Replace('*', '"') + responseString + "}");

            response.Dispose();
            response.Close();


            return(team);
        }
コード例 #3
0
        public void KickUserFromTeam(TeamInformation teaminfo, User team_member)
        {
            HttpWebRequest Req       = WebRequest.CreateHttp($"https://discord.com/api/v6/teams/" + teaminfo.id.ToString() + "/members/" + team_member.id.ToString());
            string         UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36";

            Req.Method      = "DELETE";
            Req.UserAgent   = UserAgent;
            Req.ContentType = "application/json";
            Req.Headers.Add("authorization", Token);

            using (Stream ReqResponseStream = Req.GetResponse().GetResponseStream())
            {
                using (StreamReader ReqResponse = new StreamReader(ReqResponseStream))
                {
                    string Resp = ReqResponse.ReadToEnd();
                    ReqResponse.Close();
                }
            }
        }
コード例 #4
0
        public void InviteToTeam(TeamInformation teaminfo, string user, string discriminator)
        {
            var Req = (HttpWebRequest)WebRequest.Create($"https://discord.com/api/v6/teams/" + teaminfo.id.ToString() + "/members");

            var postData = "{username: ⍚" + user + "⍚, discriminator: ⍚" + discriminator + "⍚}";

            var    data      = Encoding.ASCII.GetBytes(postData.Replace('⍚', '"'));
            string UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36";

            Req.Method      = "POST";
            Req.UserAgent   = UserAgent;
            Req.ContentType = "application/json";
            Req.Headers.Add("authorization", Token);
            Req.ContentLength = data.Length;

            using (var stream = Req.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            var response       = (HttpWebResponse)Req.GetResponse();
            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
        }