Skip to content

Instantly share code, notes, and snippets.

@SL4F
Forked from EricPanDev/discord_lootboxes.py
Last active April 3, 2024 01:50
Show Gist options
  • Select an option

  • Save SL4F/a6bd01f2519251b33ab0e0b4e63d12f8 to your computer and use it in GitHub Desktop.

Select an option

Save SL4F/a6bd01f2519251b33ab0e0b4e63d12f8 to your computer and use it in GitHub Desktop.
Automatically open discord lootboxes
# imports
import requests, json, base64, time, sys
from colorama import Fore, Style
# initial info
token = str(input(f"{Fore.RED} ▸{Fore.GREEN} [AutoLootbox] {Fore.WHITE}Copy and paste user token.\n{Fore.RED} ▸ {Fore.RESET}"))
claim = bool(input(f"{Fore.RED} ▸{Fore.GREEN} [AutoLootbox] {Fore.WHITE}Want to claim avatar decoration? (true/false)\n{Fore.RED} ▸ {Fore.RESET}"))
o=0
ui = 0
last_request_time = time.time()
X_Super = {"client_build_number":280346}
headers = {
'authorization': token,
'x-super-properties': base64.b64encode(json.dumps(X_Super).encode('utf-8')).decode('utf-8'),
}
# requests
while True:
response = requests.post('https://discord.com/api/v9/users/@me/lootboxes/open', headers=headers, timeout=10)
if 'user_lootbox_data' in response.json():
if 'opened_items' in response.json()['user_lootbox_data']:
ui = sum(response.json()['user_lootbox_data']['opened_items'].values())
if 'opened_item' in response.json():
o += 1
current_time = time.time()
time_between_requests = current_time - last_request_time
last_request_time = current_time
print(f"""{Fore.RED} ▸{Fore.GREEN} [AutoLootbox] {Fore.WHITE}Item Opened! {Fore.LIGHTBLACK_EX}{response.json()['opened_item']} {Fore.WHITE}Total Opened: {Fore.LIGHTBLACK_EX}{o} {Fore.WHITE}Inventory Items: {Fore.LIGHTBLACK_EX}{ui}
{Fore.WHITE}Time between requests: {Fore.LIGHTBLACK_EX}{round(time_between_requests, 3)} seconds.{Fore.RESET}\n""")
if "retry_after" in response.json():
time.sleep(response.json()["retry_after"] if response.json()["retry_after"] > 0 else 0)
if response.status_code == 401:
print(f"{Fore.RED} ▸ [AutoLootbox] {Fore.YELLOW}Token Invalid supplied, exiting.{Style.RESET_ALL}\n")
time.sleep(30)
sys.exit(0)
if claim == True:
if ui >= 30:
r = requests.post('https://discord.com/api/v9/users/@me/lootboxes/redeem-prize', headers=headers, timeout=10)
if r.status_code == 200:
print(f"{Fore.RED} ▸{Fore.GREEN} [AutoLootbox] {Fore.YELLOW}Claimed decoration.\n{Fore.RESET}")
time.sleep(30)
sys.exit(0)
if r.status_code == 400:
print(f"{Fore.RED} ▸ [AutoLootbox] {Fore.YELLOW}Decoration likely already claimed.\n{Fore.RESET}")
time.sleep(30)
sys.exit(0)
else:
print(f"{Fore.RED} ▸ [AutoLootbox] {Fore.YELLOW}Cannot claim decoration yet.\n{Fore.RESET}")
if "retry_after" in r.json():
time.sleep(r.json()["retry_after"] if r.json()["retry_after"] > 0 else 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment