tuaziadel1988
tuaziadel1988

Reputation: 1

Discord invite joiner

i'm trying to make a discord invite joiner, i tried this, but it is not working, how can i fix it?

and how can i make it pick the link directly from a discord channel and not by the user injecting it manually?

this is a tutorial to find your discord token

All the help will be appreciated :)

import requests

link = input('Discord Invite Link: ')
if len(link) > 6:
    link = link[19:]
apilink = "https://discordapp.com/api/v6/invite/" + str(link)

print(link)

token = "discord token"
headers={'Authorization': token}
requests.post(apilink, headers=headers)
print("All valid tokens have joined!")

Upvotes: 0

Views: 4553

Answers (4)

Echo
Echo

Reputation: 178

First of all, why are you using v6? Use v9. Here is what the updated link should look like: https://discordapp.com/api/v9/invite/...

Here is code that will work:

import requests

invite_url = input("Invite: ")
invite_code = invite_url.split("/")[-1]

authorization_token = input("Discord auth token: ")

api_invite_url = "https://discord.com/api/v9/invites/" + invite_code

resp = requests.post(api_invite_url, headers={"Authorization": authorization_token})

if resp.ok:
    print("Success!")
else:
    print("Error:" + resp.status_code, resp.text)

And this is kinda not allowed by Discord TOS, please keep that in mind when running this code!

Upvotes: 1

Kado
Kado

Reputation: 46

use v9. v6 is slow. I do not know the reason. Anyone who knows can explain.

Upvotes: 0

isopach
isopach

Reputation: 1938

You need to post the JSON data as well.

import requests

link = input('Discord Invite Link: ')
if len(link) > 6:
    link = link[19:]
apilink = "https://discordapp.com/api/v9/invite/" + str(link)

token = "discord token"

headers = {
    'Host': 'discord.com',
    'Content-Length': '2',
    'Authorization': token,
    'Content-Type': 'application/json',
    'Accept': '*/*',
    'Connection': 'close',
}

data = '{}'

response = requests.post(apilink, headers=headers, data=data, verify=False)

Upvotes: 0

user6741750
user6741750

Reputation:

The URL https://discordapp.com/api/v6/invite/ is a deprecated endpoint, and the current Discord API version is v9 - not v6.

You can just use Chrome DevTools and trace the specific requests your browser makes when joining a guild/server. Try this code, which works fine for me.

import requests

invite_url = input("Enter a Discord invite URL: ")
invite_code = invite_url.split("/")[-1]

authorization_token = input("Enter your Discord authorization token: ")

api_invite_url = "https://discord.com/api/v9/invites/" + invite_code

resp = requests.post(api_invite_url, headers={"Authorization": authorization_token})

if resp.ok:
    print("Successfully joined the server")
else:
    print(resp.status_code, resp.text)

Keep in mind that any form of automation like this might be against Discord ToS and could get your accounts flagged and disabled. Discord has many algorithms in place to detect and prevent potential abuse. So run the code with caution.

Upvotes: 0

Related Questions