Skip to content

Instantly share code, notes, and snippets.

@g1ver
Created June 12, 2023 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save g1ver/89f4aa8193d27e3961b3fbf1f832a5b2 to your computer and use it in GitHub Desktop.
Save g1ver/89f4aa8193d27e3961b3fbf1f832a5b2 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.
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();
@g1ver
Copy link
Author

g1ver commented Jun 12, 2023

How to get proper fetch data:

  1. Open Developer Tools when picking a new name for the first time.
  2. Go to Network Tab
  3. Try to pick a name that is taken (e.g. "xd")
  4. There should be a 400 status request after doing the above.
  5. Right click and click on "Use as fetch in console"
  6. Paste into script, but make sure that lines 40-43 are the same

@g1ver
Copy link
Author

g1ver commented Jun 17, 2023

Doesn't really work anymore, since Discord is heavily rate limiting the pomelo-attempt endpoint.

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