Kirby1997 / DiscordUsernameAvailabilityChecker

A Python script to check if words from a wordlist are available as a Discord username
GNU General Public License v3.0
5 stars 6 forks source link

was trying to add proxy support to the code, but imma noob. Let me know if this helps or you can help me figure this out. #3

Open Zyfea opened 1 year ago

Zyfea commented 1 year ago

import time import requests import requests

Set the Discord authorization token

token = "" # INSERT YOUR TOKEN INTO THE QUOTES. DO NOT SHARE THIS TOKEN.

IF SHARING THIS FILE, REMEMBER TO REMOVE YOUR TOKEN

headers = {"Authorization": token}

with open("proxies.txt") as proxy: proxies = [line.strip() for line in proxy]

Discord username API endpoint

endpoint = "https://discord.com/api/v10/users/@me/pomelo"

Load the list of usernames from the file

with open("usernames.txt") as file: usernames = [line.strip() for line in file]

available_usernames = []

Loop through each username in the list and check availability

for username in usernames: url = endpoint body = { "username": username } response = requests.post(url, headers=headers, json=body, proxies={"http": proxies, "https":proxies},timeout=3)

# Rate limit check
if response.status_code == 429:
    sleep_time = response.json()["retry_after"]
    print(f"Rate limit hit. Sleeping for {sleep_time}s")
    time.sleep(sleep_time)
    response = requests.post(url, headers=headers, json=body, proxies=proxies)

#username available check
if response.json()['code'] == 40001:
    print(f"{username} is available")
    available_usernames.append(username)

#Username unavailable check
elif response.json()['code'] == 50035:
    print(f"{username} is taken")

#Some other error
else:
    print(f"Error checking {username}: {response.json()['message']}")

Write available usernames to a file

with open("available_usernames.txt", "w") as file: file.write("\n".join(available_usernames))

FatedZ commented 1 year ago

did you get it working by any chance??