This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdiscord.go
68 lines (61 loc) · 1.81 KB
/
discord.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package apps
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"sync"
"github.com/fatih/color"
)
type discordResponse struct {
Errors struct {
Email struct {
Errors []struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"_errors"`
} `json:"email"`
} `json:"errors"`
}
func Discord(wg *sync.WaitGroup, email string, showFalse bool) {
defer wg.Done()
var endpoint string = "https://discord.com/api/v9/auth/register"
var jsonStr = []byte(`{"email":"` + email + `","username":"asdsadsad","password":"q1e31e12r13*","invite":null,"consent":true,"date_of_birth":"1973-05-09","gift_code_sku_id":null,"captcha_key":null,"promotional_email_opt_in":false}`)
client := &http.Client{}
r, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(jsonStr)) // URL-encoded payload
if err != nil {
log.Fatal(err)
}
r.Header.Add("Content-Type", "application/json")
r.Header.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36")
r.Header.Add("X-Debug-Options", "bugReporterEnabled")
res, err := client.Do(r)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 400 {
body, _ := ioutil.ReadAll(res.Body)
var response discordResponse
json.Unmarshal(body, &response)
if len(response.Errors.Email.Errors) > 0 {
if response.Errors.Email.Errors[0].Code == "EMAIL_ALREADY_REGISTERED" {
fmt.Println("Discord \U0001f440")
} else {
if showFalse {
fmt.Println("Discord", color.RedString(" [Not here!]"))
}
}
} else {
if showFalse {
fmt.Println("Discord", color.RedString(" [Not here!]"))
}
}
} else if res.StatusCode == 429 {
color.Red("Too many requests to Discord!")
} else {
color.Red("Couldn't check Discord!")
}
}