Skip to content

Instantly share code, notes, and snippets.

@g1ver
Created June 7, 2023 07:44
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/8f004db0f8341b965faed0ce3eef4694 to your computer and use it in GitHub Desktop.
Save g1ver/8f004db0f8341b965faed0ce3eef4694 to your computer and use it in GitHub Desktop.
discord name trying script
namelist = [] // names here
async function processNames() {
for (const name of namelist) {
try {
const res = await makeRequest(name);
if (res.ok) {
console.log(`Username ${name} is available.`);
break;
}
} 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", {
// config, get from network tab of devtools after trying to change name
});
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 {
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 7, 2023

New Discord names are out. Use this script to automatically try a bunch of names.

Here are the name constraints:

  • Usernames must be at least 2 characters and at most 32 characters long
  • Usernames are case insensitive and forced lowercase
  • Usernames cannot use any other special characters besides underscore ( _ ) and period ( . )
  • Usernames cannot use 2 consecutive period characters ( . )

NOTE: You can only change your name once every two hours.

I'm sure name checking can be done through the API, but this was a quick solution.

@g1ver
Copy link
Author

g1ver commented Jun 7, 2023

I found this API endpoint that can be used to test for available names: https://discord.com/api/v9/users/@me/pomelo-attempt

It seems to only be available to users who have been granted access to pick a new name, but haven't locked in a new one. So, if you want to check for a lot of names, do not register a new username before checking; otherwise, you will lose access to this endpoint.

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