Skip to content

Instantly share code, notes, and snippets.

@EricPanDev
Last active April 3, 2024 01:32
Show Gist options
  • Save EricPanDev/4238407328fe08ab9b1ec8b1a00322aa to your computer and use it in GitHub Desktop.
Save EricPanDev/4238407328fe08ab9b1ec8b1a00322aa to your computer and use it in GitHub Desktop.
Automatically open discord lootboxes
token = input("Copy and paste user token: ")
import requests, json, base64, time, sys
X_Super = {"client_build_number":280346}
headers = {
'authorization': token,
'x-super-properties': base64.b64encode(json.dumps(X_Super).encode('utf-8')).decode('utf-8'),
}
o=0
ui = 0
last_request_time = time.time()
while True:
response = requests.post('https://discord.com/api/v9/users/@me/lootboxes/open', headers=headers)
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("[AutoLootbox] >> Item Opened!", response.json()['opened_item'], "Total Opened:",o, "Inventory Items:", ui)
print("[AutoLootbox] >> Time between requests:", time_between_requests, "seconds")
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("[AutoLootbox] >> Token Invalid supplied, exiting.")
sys.exit(0)
@GenertP
Copy link

GenertP commented Apr 1, 2024

lol

@MetaShrimps
Copy link

ts just puts my token in the console and doesnt do anything

@Paasdag
Copy link

Paasdag commented Apr 1, 2024

For people who dont have python / dont know how to install it i made an exe version

@EricPanDev
Copy link
Author

@MetaShrimps If it doesn't do anything that most likely means you put a invalid token or you didn't press enter after pasting your token :)

@TheDarknessSurroundsYou
Copy link

@MetaShrimps are you using python?

@SL4F
Copy link

SL4F commented Apr 2, 2024

here's a version that attempts to claim the decoration after 30 items, also looks more organised.

# original: https://gist.github.com/EricPanDev/4238407328fe08ab9b1ec8b1a00322aa
# modified by: SL4F
# imports
import requests, json, base64, time, sys
from colorama import Fore, Style
# initial info
token = input(f"{Fore.RED}{Fore.GREEN} [AutoLootbox] {Fore.WHITE}Copy and paste user token.\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")
        sys.exit(0)
    if o >= 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}")
        sys.exit(0)
      else:
        print(f"{Fore.RED} ▸ [AutoLootbox] {Fore.YELLOW}Cannot claim decoration.\n{Fore.RESET}")```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment