Skip to content

Commit 6dc3a1c

Browse files
committed
fix to build num + test guild option
1 parent 10b40b6 commit 6dc3a1c

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

client_info.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,11 @@
1919
from main import request_client
2020

2121
def get_client_build_number():
22-
client_request = request_client.get(f'https://discord.com/app', headers={'User-Agent': 'Mozilla/5.0'}).text
23-
jsFileRegex = re.compile(r'([a-zA-z0-9]+)\.js', re.I)
24-
for asset in jsFileRegex.findall(client_request)[::-1]:
25-
if asset != "invisible":
26-
break
27-
28-
assetFileRequest = request_client.get(f'https://discord.com/assets/{asset}.js', headers={'User-Agent': 'Mozilla/5.0'}).text
29-
try:
30-
build_info_regex = re.compile(r'Build Number: "\)\.concat\("([0-9]{4,8})"')
31-
build_info_strings = build_info_regex.findall(assetFileRequest)
32-
build_num = build_info_strings[0]
33-
except (RuntimeError, TypeError, NameError):
34-
raise Exception(f"couldn't fetch discord build num from {asset}.js")
35-
36-
return int(build_num)
22+
res = request_client.get("https://discord.com/login").text
23+
file_with_build_num = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+)\.js').findall(res)[-2]+'.js'
24+
req_file_build = request_client.get(file_with_build_num).text
25+
index_of_build_num = req_file_build.find('buildNumber')+24
26+
return int(req_file_build[index_of_build_num:index_of_build_num+6])
3727

3828
discord_build = get_client_build_number()
3929
super_properties = {

main.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# License v3.0. A copy of this license is available at
66
# https://www.gnu.org/licenses/agpl-3.0.en.html
77

8-
app_version = "v1.2.3"
8+
app_version = "v1.2.4"
99

1010
import time
1111
import sys
@@ -60,7 +60,7 @@
6060
import restore
6161
c = console.prnt()
6262

63-
os.system('cls')
63+
os.system('cls' if os.name == 'nt' else 'clear')
6464
try:
6565
github_data = request_client.get("https://api.github.com/repos/ItsChasa/Discord-Backup/releases/latest").json()
6666
app_latest_ver = github_data['tag_name']
@@ -316,6 +316,22 @@
316316
c.info('For additional help, join the Discord Server: https://discord.gg/MUP5TSEPc4')
317317
c.info("If it's invalid, go to https://chasa.wtf and click the Discord icon.")
318318

319+
elif choice == 999:
320+
c.info("Test Guild Creation (TLS Client)")
321+
c.inp("Token: ", end="")
322+
token = input()
323+
restore.restore.create_guild(
324+
token,
325+
{
326+
"name": "Test Server",
327+
"icon": None,
328+
"channels": [],
329+
"system_channel_id": "0",
330+
"guild_template_code": "2TffvPucqHkN",
331+
},
332+
verbose=True
333+
)
334+
319335
else:
320336
c.fail(f"Invalid Choice")
321337

restore.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ def _message(self, guild, channel, content) -> bool:
106106
print(response.json())
107107
return False
108108

109+
@staticmethod
110+
def create_guild(token, payload, verbose=False):
111+
req = request_client.post("https://discord.com/api/v9/guilds",
112+
headers=build_headers("post", debugoptions=True, discordlocale=True, superprop=True, authorization=token, timezone=True, origin="https://discord.com"),
113+
json=payload
114+
)
115+
116+
try: guild_id = req.json()['id']
117+
except:
118+
if verbose:
119+
print(f"Failed to create guild: {req.status_code}")
120+
print(req.text)
121+
return None, req
122+
else: return guild_id, req
123+
109124
def servers(self):
110125
channels = [
111126
{
@@ -166,13 +181,9 @@ def servers(self):
166181
"guild_template_code": "2TffvPucqHkN",
167182
}
168183

169-
req = request_client.post("https://discord.com/api/v9/guilds",
170-
headers=build_headers("post", debugoptions=True, discordlocale=True, superprop=True, authorization=self.token, timezone=True, origin="https://discord.com"),
171-
json=payload
172-
)
184+
guild_id, req = self.create_guild(self.token, payload)
173185

174-
try: guild_id = req.json()['id']
175-
except:
186+
if not guild_id:
176187
self.c.fail(f"Failed to create guild: {req.status_code}")
177188
self.c.fail(req.text)
178189
self.fatal_error = "Failed to create guild"

0 commit comments

Comments
 (0)