-
-
Save Infinitay/cdb492366cde666eb4ebb54034fbddc6 to your computer and use it in GitHub Desktop.
Check discord names using the pomelo-attempt endpoint. This endpoint is only available if you have the option to pick a new name for the first time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function processNames() { | |
for (const name of namelist) { | |
try { | |
const res = await makeRequest(name); | |
if (res.ok) { | |
const data = await res.json(); | |
if (data.taken) { | |
console.log(`[-] ${name} was taken.`) | |
continue; | |
} | |
console.log(`[+] ${name} is available.`) | |
}); | |
} | |
} catch (error) { | |
console.error(`An error occurred while processing username ${name}:`, error); | |
} | |
} | |
} | |
async function makeRequest(name) { | |
const res = await fetch("https://discord.com/api/v9/users/@me/pomelo-attempt", { | |
"credentials": "include", | |
"headers": { | |
"User-Agent": "", | |
"Accept": "*/*", | |
"Accept-Language": "", | |
"Content-Type": "", | |
"Authorization": "", | |
"X-Super-Properties": "", | |
"X-Discord-Locale": "", | |
"X-Discord-Timezone": "", | |
"X-Debug-Options": "", | |
"Alt-Used": "", | |
"Sec-Fetch-Dest": "", | |
"Sec-Fetch-Mode": "", | |
"Sec-Fetch-Site": "", | |
"Sec-GPC": "" | |
}, | |
"referrer": "https://discord.com/channels/@me", | |
"body": `{\"username\":\"${name}\"}`, | |
"method": "POST", | |
"mode": "cors" | |
}); | |
if (res.ok) { | |
return res; | |
} else if (res.status === 429) { | |
const retryAfter = res.headers.get('Retry-After'); | |
const delay = retryAfter ? parseInt(retryAfter) * 1000 : 1000; // default delay of 1 second | |
//console.log(`Rate limit exceeded. Retrying after ${delay / 1000} seconds.`); | |
await sleep(delay); // wait for the specified delay before retrying | |
return makeRequest(name); // retry the request | |
} else if (res.status === 401) { | |
throw new Error(`You do not have access to this endpoint.`); | |
} else { | |
throw new Error(`Request failed with status ${res.status}`); | |
} | |
} | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
processNames(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment