Skip to content

Instantly share code, notes, and snippets.

@oSumAtrIX
Last active April 3, 2024 11:24
Show Gist options
  • Star 42 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save oSumAtrIX/8c0540c80ca2b91efa18d137e239570f to your computer and use it in GitHub Desktop.
Save oSumAtrIX/8c0540c80ca2b91efa18d137e239570f to your computer and use it in GitHub Desktop.
Useful snippets for Discord

Discord console scripts

My collection of scripts for Discord.

Scripts

  • friend_invitelink.js: Generate a friend invite link
  • clientside_nitro.js: Spoof the client and enable client side Discord Nitro
webpackChunkdiscord_app.push([[[Math.random()]],{},q=>Object.values(q.c).find(e=>e.exports?.default?.getCurrentUser).exports.default.getCurrentUser().premiumType=2])
@yumiruuwu
Copy link

Just replace default with Z and it's work again

Old:

webpackChunkdiscord_app.push([[[""]],{},q=>Object.values(q.c).find(e=>e.exports?.default?.createFriendInvite).exports.default.createFriendInvite().then(console.log)])

New:

webpackChunkdiscord_app.push([[[""]],{},q=>Object.values(q.c).find(e=>e.exports?.Z?.createFriendInvite).exports.Z.createFriendInvite().then(console.log)])

@oSumAtrIX
Copy link
Author

Just replace default with Z and it's work again

Old:

webpackChunkdiscord_app.push([[[""]],{},q=>Object.values(q.c).find(e=>e.exports?.default?.createFriendInvite).exports.default.createFriendInvite().then(console.log)])

New:

webpackChunkdiscord_app.push([[[""]],{},q=>Object.values(q.c).find(e=>e.exports?.Z?.createFriendInvite).exports.Z.createFriendInvite().then(console.log)])

Cool thx

@Faulty-Windows
Copy link

Sadly doesn't work anymore. Does anyone have a new way to do this yet?

It does work, I just tested it

@XstreamSpeed
Copy link

Sadly doesn't work anymore. Does anyone have a new way to do this yet?

It does work, I just tested it

Is it against the Discord TOS?

@oSumAtrIX
Copy link
Author

@Depthify
Copy link

Where do I find the button to create an invite?

@oSumAtrIX
Copy link
Author

It generates one right in the console @Depthify

@Arikatsu
Copy link

Where do I find the button to create an invite?

u paste it in the console, it logs a string of characters, u can use that and add it infront of https://discord.gg/<string>

@zerver0
Copy link

zerver0 commented Dec 3, 2022

is it possible to make a permanent invite link? because I can see that there's an max uses and expire time and it absolutely is not close to infinity

@zisra
Copy link

zisra commented Dec 3, 2022

No

@chill389cc
Copy link

Here is a version which automatically parses out the code from the output and wraps it in a discord.gg link for you:

webpackChunkdiscord_app.push([[[""]],{},q=>Object.values(q.c).find(e=>e.exports?.Z?.createFriendInvite).exports.Z.createFriendInvite().then(x => console.log('https://discord.gg/' + x.code))])

@Matojeje
Copy link

Sadly doesn't work anymore. Does anyone have a new way to do this yet?

You could use protocol links

e.g. discord://-/users/900156861616111646

to use it in discord you'd do 'discord://-/users/900156861616111646'

@TRH-Raz This is great! How did you find this? Are there more things you can do with protocol links?

@kylianpl
Copy link

I managed to create an invite by resending the invite post request and changing the body to {"max_age":0,"max_uses":0,"temporary":false}
It will still expire in a week but there is no max uses

@Aelipus
Copy link

Aelipus commented Feb 6, 2023

@KylianAlex I’m very new to this, but what do you mean with “body”?

@kylianpl
Copy link

kylianpl commented Feb 6, 2023

(i'm talking about the friend invite link, not the clientside nitro)
@Aelipus in https requests, there is the headers (where the authorization token and other data are sent) and the body when you send a POST/PUT... request. It can be in different format (a png if you're POSTing an image, json data for additional data ex sending a discord message), in the case of this script, it just send a POST request to https://discord.com/api/v9/users/@me/invites with your token in the headers and {} (an empty json) in the body.
To have the body {"max_age":0,"max_uses":0,"temporary":false} i created an invite to a server in discord and looked at the request, i tried resending the request (it's possible with firefox but not chrome iirc) and changing the url to https://discord.com/api/v9/users/@me/invites and discord responded me a new invite link

@RedBoardDev
Copy link

RedBoardDev commented Feb 22, 2023

(i'm talking about the friend invite link, not the clientside nitro) @Aelipus in https requests, there is the headers (where the authorization token and other data are sent) and the body when you send a POST/PUT... request. It can be in different format (a png if you're POSTing an image, json data for additional data ex sending a discord message), in the case of this script, it just send a POST request to https://discord.com/api/v9/users/@me/invites with your token in the headers and {} (an empty json) in the body. To have the body {"max_age":0,"max_uses":0,"temporary":false} i created an invite to a server in discord and looked at the request, i tried resending the request (it's possible with firefox but not chrome iirc) and changing the url to https://discord.com/api/v9/users/@me/invites and discord responded me a new invite link

Hi !
I want to make the same but with infinite link not just for one week. I've read your message, but I don't understand where set this body. Because when I try on postman, I've not authorization. Idk where put my token because on bearer it's not good.

@kylianpl
Copy link

you need to break discord tos (if you used the code above you were already breaking the tos) and use an account token instead of a bearer and while you do not abuse you should not get banned, just look at a tutorial or look at the "Authorization" header when sending a message, then put your token like so Authorization: abcdef in the header of the "https://discord.com/api/v9/users/@me/invites", last time i tried the generated link still for one week, maybe it's a discord limitation, if you do it and the link is infinite let me know

@RedBoardDev
Copy link

actually, I've this error:
Error: Bad Request
Your client has issued a malformed or illegal request.
with 400 Bad request
I try with this:
https://discord.com/api/v9/users/@me/invites
bearer token
and this body:
{
"max_age":0,
"max_uses":0,
"temporary":false
}

Idk if we can, but I think we can because it's like server invitation

@kylianpl
Copy link

kylianpl commented Feb 22, 2023

actually, I've this error: Error: Bad Request Your client has issued a malformed or illegal request. with 400 Bad request I try with this: https://discord.com/api/v9/users/@me/invites bearer token and this body: { "max_age":0, "max_uses":0, "temporary":false }

Idk if we can, but I think we can because it's like server invitation

in this case the 400 Bad Request is caused because the body is json but you didn't set Content-Type: application/json in the headers

if you send a bad token, you will get a 401 Unauthorized

@RedBoardDev
Copy link

Content-Type: application/json is set by default so it's not this

@kylianpl
Copy link

kylianpl commented Feb 22, 2023

are you sure you correctly sent Authorization: Pi3da4xc9drZjubtFcJ65Vhg.6Nz6BK.qmXyUTGAKdKXzgyMXFxgptr3WyjCEtKSk8SuD9 (this is a fake token for example purposes)
a bearer token will always unauthorized

@RedBoardDev
Copy link

image

@kylianpl
Copy link

kylianpl commented Feb 22, 2023

oh, the request is a get, you need to send a post request (it's nearby the url)

@kylianpl
Copy link

kylianpl commented Feb 22, 2023

i tried postman and it seems like the auth can't send only the token, you need to manually set the Authorization from the headers
if you still need help contact me by discord at discord.gg/77rPTQTs
Screenshot_20230222_235959

@kylianpl
Copy link

kylianpl commented Feb 22, 2023

it seems useless to send a request manually now, i just tried and it still expires after 1 week or 5 max uses

@RedBoardDev
Copy link

What have you try the put on the body ?

@kylianpl
Copy link

it seems to ignore input or use input that i don't know of (add me as friend https://discord.gg/77rPTQTs if you want to talk more or ask me questions)

@RobinRMC
Copy link

RobinRMC commented Apr 6, 2023

This code doesn't work anymore, does it?

@XplosiON1232
Copy link

This code doesn't work anymore, does it?

nope :(

@B-rancher
Copy link

anyone know why they got rid of it? it was so cool

@yumiruuwu
Copy link

anyone know why they got rid of it? it was so cool

They didn't get rid of it. If you want to use it, Vencord has a plugin that allows you to create friend invites. But still expire after 5 uses or a week.

@002-sans
Copy link

I saw that feature on discord.js-selfbot-v13 module, idk if that can help somebody xD

https://discordjs-self-v13.netlify.app/#/docs/docs/main/class/ClientUser?scrollTo=createFriendInvite

@RedBoardDev
Copy link

I saw that feature on discord.js-selfbot-v13 module, idk if that can help somebody xD

https://discordjs-self-v13.netlify.app/#/docs/docs/main/class/ClientUser?scrollTo=createFriendInvite

Oh thanks !
`void async function () {
const { createFriendInvite } = webpackChunkdiscord_app.push([[Symbol()], {}, req => (
Object.values(req.c).find(m => m?.exports?.Z?.createFriendInvite)
)]).exports.Z;

// Prevent memory leak
webpackChunkdiscord_app.pop();

console.log(Friend invite: https://discord.gg/${(await createFriendInvite()).code});
}();` works if you send that on the console of discord.com/app
But I can't find something to use on a javascript script :(

@RedBoardDev
Copy link

and for this code:
client.user.createFriendInvite() .then(console.log) .catch(console.error);

It's work. But you can be banned of discord x': Use a self-bot is not allow by discord.
And the link create by this code can be use just once. I've search how to change that but I've not found... If someone as an idea I'm here ;)

@phoebe-leong
Copy link

does anyone know how createFriendInvite() even works? I'm thinking maybe there might be parameters we could put in and since we're not doing that it just defaults to 5 uses and expiry after a week

@RedBoardDev
Copy link

RedBoardDev commented Aug 13, 2023

Hi ! I'm coming with news.
Actually, it's no longer possible to do like before with the link discord.gg like server invitation.
Like I said before (May 29), you still can create a self-bot and create link with this code:
client.user.createFriendInvite() .then(console.log) .catch(console.error);

But I've found nothing to change settings, so it's 5 person per link and expire after 1 week.
Self-bot aren't allowed by discord, so be careful with that.

BUUUT, I have find an another way !
You can do the link with 'https://discord.com/users/USER_iD'. For example with mine: https://discord.com/users/419926802366988292
You can see how that is on my github profil.
You directly have the profil of the person like in discord so its nice too ;)

@RobinRMC
Copy link

It's still possible by using client mods like BetterDiscord or Vencord.

@dgxo
Copy link

dgxo commented Aug 16, 2023

I modified some of the code RedBoardDev to work, and it works consistently. Enter this into your browser/discord dev tools console and it will give you a new invite code in an alert.

const { createFriendInvite } = webpackChunkdiscord_app.push([[Symbol()], {}, req => (
  Object.values(req.c).find(m => m?.exports?.Z?.createFriendInvite)
)]).exports.Z;
webpackChunkdiscord_app.pop();
let msg = `Here's your friend invite: https://discord.gg/${(await createFriendInvite()).code}`;
console.log(msg);
alert(msg);
return(msg);

Shorter version:

(async function(){const { createFriendInvite: a } = webpackChunkdiscord_app.push([[Symbol()], {}, (req) => Object.values(req.c).find((m) => m?.exports?.Z?.createFriendInvite)]).exports.Z;webpackChunkdiscord_app.pop();let m = `Here's your friend invite: https://discord.gg/${(await a()).code}`;alert(m);})()

If it's easier, you can even make a bookmark(let) with this as the contents:

javascript:(async function(){const { createFriendInvite: a } = webpackChunkdiscord_app.push([[Symbol()], {}, (req) => Object.values(req.c).find((m) => m?.exports?.Z?.createFriendInvite)]).exports.Z;webpackChunkdiscord_app.pop();let m = `Here's your friend invite: https://discord.gg/${(await a()).code}`;console.log(m);alert(m);return m;})()

@Indusz
Copy link

Indusz commented Aug 19, 2023

Hi ! I'm coming with news. Actually, it's no longer possible to do like before with the link discord.gg like server invitation. Like I said before (May 29), you still can create a self-bot and create link with this code: client.user.createFriendInvite() .then(console.log) .catch(console.error);

But I've found nothing to change settings, so it's 5 person per link and expire after 1 week. Self-bot aren't allowed by discord, so be careful with that.

BUUUT, I have find an another way ! You can do the link with 'https://discord.com/users/USER_iD'. For example with mine: https://discord.com/users/419926802366988292 You can see how that is on my github profil. You directly have the profil of the person like in discord so its nice too ;)

Unfortunately this only works if you have a mutual server with the person in question.

@pxtzel
Copy link

pxtzel commented Feb 4, 2024

Here's a patched version that works for now, it will log the invite link to the console.

webpackChunkdiscord_app.push([
    [Symbol()], {},
    async r => r?.c && console.log('https://discord.gg/' + (await Object.values(r.c).find(a => a.exports?.default?.createFriendInvite).exports.default.createFriendInvite()).code)
]);
!!webpackChunkdiscord_app.pop();

Minified:

webpackChunkdiscord_app.push([[Symbol()],{},async e=>e?.c&&console.log("discord.gg/"+(await Object.values(e.c).find(e=>e.exports?.default?.createFriendInvite).exports.default.createFriendInvite()).code)]);!!webpackChunkdiscord_app.pop();

@NightMean
Copy link

Here's a patched version that works for now, it will log the invite link to the console.

webpackChunkdiscord_app.push([
    [Symbol()], {},
    async r => r?.c && console.log('https://discord.gg/' + (await Object.values(r.c).find(a => a.exports?.default?.createFriendInvite).exports.default.createFriendInvite()).code)
]);
!!webpackChunkdiscord_app.pop();

Minified:

webpackChunkdiscord_app.push([[Symbol()],{},async e=>e?.c&&console.log("discord.gg/"+(await Object.values(e.c).find(e=>e.exports?.default?.createFriendInvite).exports.default.createFriendInvite()).code)]);!!webpackChunkdiscord_app.pop();

Thanks, this worked like a charm!

@SwiftWinds
Copy link

Here's a patched version that works for now, it will log the invite link to the console.

webpackChunkdiscord_app.push([
    [Symbol()], {},
    async r => r?.c && console.log('https://discord.gg/' + (await Object.values(r.c).find(a => a.exports?.default?.createFriendInvite).exports.default.createFriendInvite()).code)
]);
!!webpackChunkdiscord_app.pop();

Minified:

webpackChunkdiscord_app.push([[Symbol()],{},async e=>e?.c&&console.log("discord.gg/"+(await Object.values(e.c).find(e=>e.exports?.default?.createFriendInvite).exports.default.createFriendInvite()).code)]);!!webpackChunkdiscord_app.pop();

Does this have an expiry? Or a max uses? I prefer no expiry and no max uses.

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