Skip to content

Instantly share code, notes, and snippets.

@max1mde
Last active July 17, 2024 10:02
Show Gist options
  • Save max1mde/437532d7b08f7e54c2bb7147828ab0e7 to your computer and use it in GitHub Desktop.
Save max1mde/437532d7b08f7e54c2bb7147828ab0e7 to your computer and use it in GitHub Desktop.
Discord friend invite link generator - Console script (Tested 7/17/2024)

Note

This method is designed to be more resilient to updates, as it dynamically searches for the createFriendInvite function instead of relying on a hardcoded, currently working method that may become outdated.

Discord Friend Invite Generator

image

This script generates a friend invite link for Discord by recursively searching for the createFriendInvite method within the Discord web application.

Usage

  1. Open the Discord web application in your browser.
  2. Open the browser's Developer Tools (usually by pressing F12 or Ctrl+Shift+I).
  3. Navigate to the Console tab.
  4. Copy and paste the script below into the console and press Enter.
  5. You should now see an output like this:

image

const deepSearchForMethod = (obj, methodName, path = '', visited = new Set(), maxDepth = 10, depth = 0) => {
if (depth > maxDepth || visited.has(obj)) {
return null;
}
visited.add(obj);
for (let key in obj) {
if (obj[key] && typeof obj[key] === 'object') {
if (obj[key][methodName]) {
console.log(`Found ${methodName} at path: ${path}.${key}`);
return obj[key][methodName];
}
const result = deepSearchForMethod(obj[key], methodName, `${path}.${key}`, visited, maxDepth, depth + 1);
if (result) return result;
}
}
return null;
};
const searchForFriendInviteMethod = async () => {
webpackChunkdiscord_app.push([
[Symbol()], {},
async r => {
if (r) {
const methodName = 'createFriendInvite';
const foundMethod = deepSearchForMethod(r, methodName);
if (foundMethod) {
try {
const invite = await foundMethod();
console.log('Your friend invite link: https://discord.gg/' + invite.code);
} catch (e) {
console.error(`Error creating friend invite:`, e);
}
} else {
console.error(`${methodName} method not found.`);
}
} else {
console.error("r is undefined or null.");
}
}
]);
!!webpackChunkdiscord_app.pop();
};
searchForFriendInviteMethod();
const deepSearchForMethod=(e,r,t="",n=new Set,o=10,i=0)=>{if(i>o||n.has(e))return null;for(let d in n.add(e),e)if(e[d]&&"object"==typeof e[d]){if(e[d][r])return console.log(`Found ${r} at path: ${t}.${d}`),e[d][r];let a=deepSearchForMethod(e[d],r,`${t}.${d}`,n,o,i+1);if(a)return a}return null},searchForFriendInviteMethod=async()=>{webpackChunkdiscord_app.push([[Symbol()],{},async e=>{if(e){let r="createFriendInvite",t=deepSearchForMethod(e,r);if(t)try{let n=await t();console.log("Your friend invite link: https://discord.gg/"+n.code)}catch(o){console.error("Error creating friend invite:",o)}else console.error(`${r} method not found.`)}else console.error("r is undefined or null.")}]),webpackChunkdiscord_app.pop()};searchForFriendInviteMethod();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment