#Discord Authorized App Usage

1 messages · Page 1 of 1 (latest)

spark spade
#

Hello, I have an authorized app linked to my account, I have the Join Server For You enabled. Can someone help me make a script that will join a server for me.

I have also read: https://discord.com/developers/docs/resources/guild#add-guild-member
but I don't understand if you could make a code block and explain it that would be appreciated.

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

dusty boltBOT
#
Too Many Tags

Please use either the disnake or python tag, but not both. If your question pertains to disnake, please use the disnake tag. If your question is a general python question that does not depend on disnake, please use the python tag.
I've taken a guess based on the contents of your message which your question is actually about.

If you believe this to be in error, please let us know.

still phoenix
#

Not going to just write the code for you. The docs explain it fairly well. You need a put request to that url (sub guild_id and member_id)

still phoenix
#

which part

spark spade
still phoenix
spark spade
#

or all of the

still phoenix
#

you need those to get your token

#

then the API url is
https://discord.com/api/v10/

spark spade
still phoenix
#

https://discord.com/api/v10/guilds/{guild.id}/members/{user.id}

#

Do a PUT request to that URL with the correct headers

echo field
#

check the discord docs

spark spade
#

would also be careful with this as discord isn’t too fond of these type of bots

spark spade
#

since discord had the option lol

spark spade
spark spade
#
import requests

API_ENDPOINT = 'https://discord.com/api'
CLIENT_ID = 'CLIENT ID'
CLIENT_SECRET = 'CLIENT SECRET'
REDIRECT_URI = "https://google.com"

def exchange_code(code):
    data = {
        'client_id': CLIENT_ID,
        'client_secret': CLIENT_SECRET,
        'grant_type': 'authorization_code',
        'code': code,
        'redirect_uri': REDIRECT_URI
    }
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    r = requests.post('%s/oauth2/token' % API_ENDPOINT, data=data, headers=headers)
    r.raise_for_status()
    return r.json()

def add_to_guild(access_token, userID, guildID):
    url = f"{API_ENDPOINT}/guilds/{guildID}/members/{userID}"
    botToken = "BOT TOKEN"
    data = {
        "access_token" : access_token,
    }
    headers = {
        "Authorization" : f"Bot {botToken}",
        'Content-Type': 'application/json'
    }
    response = requests.put(url=url, headers=headers, json=data)
    print(response.text)

code = exchange_code('ACCESS CODE')['access_token']
add_to_guild(code, 'USER ID', 'SERVER ID')

i have this but it give me error of

{"message": "Missing Permissions", "code": 50013}