-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
28 lines (22 loc) · 1.12 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
import requests, json, htmlify
TOKEN = open('token.txt', 'r').read()
user_to_channel = lambda user_id: requests.post('https://discord.com/api/v9/users/@me/channels', json={'recipients':[user_id]}, headers={'authorization':TOKEN}).json()['id']
def save_data(id):
total = []
data = requests.get(f'https://discord.com/api/v9/channels/{id}/messages?limit=50', headers={'authorization':TOKEN}).json()
while True:
total.append(data)
if len(data) < 50:
break
else:
last = data[49]['id']
data = requests.get(f'https://discord.com/api/v9/channels/{id}/messages?before={last}&limit=50', headers={'authorization':TOKEN}).json()
open('data.json', 'w').write(json.dumps([x for y in total for x in y]))
download_type = int(input('\u001b[34mPlease select which type of channel you want to download?\u001b[0m\n\n1. User DMs\n2. Text channel\n\n> '))
id = 0
if download_type == 1:
id = user_to_channel(int(input('\n\u001b[34mEnter their user ID:\u001b[0m ')))
elif download_type == 2:
id = int(input('\n\u001b[34mEnter the channel ID:\u001b[0m '))
save_data(id)
htmlify.write(id)