-
Notifications
You must be signed in to change notification settings - Fork 59
/
main.py
97 lines (84 loc) · 3.56 KB
/
main.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import colorama, tls_client
sub_ids = []
__guild_id__ = input("Guild ID: ")
colorama.init(convert=True)
class Nitro:
def __init__(self, token: str):
self.token = token
self.headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US",
"authorization": token,
"referer": "https://discord.com/channels/@me",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9007 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36",
"x-debug-options": "bugReporterEnabled",
"x-discord-locale": "en-US",
"x-super-properties": "eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiRGlzY29yZCBDbGllbnQiLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfdmVyc2lvbiI6IjEuMC45MDA3Iiwib3NfdmVyc2lvbiI6IjEwLjAuMTkwNDMiLCJvc19hcmNoIjoieDY0Iiwic3lzdGVtX2xvY2FsZSI6ImVuLVVTIiwiY2xpZW50X2J1aWxkX251bWJlciI6MTYxODQyLCJjbGllbnRfZXZlbnRfc291cmNlIjpudWxsfQ=="
}
self.session = tls_client.Session(client_identifier="chrome_107")
self.sub_ids = []
def removeTokenFromTxt(self):
with open("tokens.txt", "r") as f:
lines = f.readlines()
with open("tokens.txt", "w") as f:
for line in lines:
if line.strip("\n") != self.token:
f.write(line)
def hasNitro(self):
sex = self.session.get(
"https://discord.com/api/v9/users/@me/guilds/premium/subscription-slots",
headers=self.headers,
)
if sex.status_code in [403, 401]:
return self._extracted_from_hasNitro_7('Token is invalid, removing.')
try:
for sub in sex.json():
self.sub_ids.append(sub["id"])
except Exception as e:
print(e)
print(sex.text)
if len(self.sub_ids) == 0:
return self._extracted_from_hasNitro_7('Token has no nitro, removing.')
log(f"{colorama.Fore.GREEN}Token has nitro.")
return True
# TODO Rename this here and in `hasNitro`
def _extracted_from_hasNitro_7(self, arg0):
log(f"{colorama.Fore.RED}{arg0}")
self.removeTokenFromTxt()
return False
def boostServer(self, guildID):
for i in range(len(self.sub_ids)):
self.headers["Content-Type"] = "application/json"
r = self.session.put(
url=f"https://discord.com/api/v9/guilds/{guildID}/premium/subscriptions",
headers=self.headers,
json={
"user_premium_guild_subscription_slot_ids": [f"{self.sub_ids[i]}"]
},
)
if r.status_code == 201:
log(
f"{colorama.Fore.GREEN}Boosted {i + 1} of {len(sub_ids)} from {self.token[25:]}"
)
elif r.status_code == 400:
log(
f"{colorama.Fore.YELLOW}Boost already used {i + 1} of {len(sub_ids)} from {self.token[25:]}"
)
else:
log(f"{colorama.Fore.RED}ERROR: {r.status_code}")
def log(text):
print(f"{text}{colorama.Fore.RESET}")
def main():
with open("tokens.txt", "r") as f:
tokens = f.read().splitlines()
for token in tokens:
nitro = Nitro(token)
if nitro.hasNitro():
nitro.boostServer(__guild_id__)
if __name__ == "__main__":
main()
input("Press enter to exit.")