简体   繁体   中英

Why does the guilds.join scope exist?

I was wondering what the use of the guilds.join scope is, and can you show some examples of how to use it? I'm just curious of what people use this for.

Can I use it to join my bot support server?

guilds.join allows you to add the user who used the URL to a guild the bot is in. Note the bot does need CREATE_INSTANT_INVITE permissions in that guild.

You will need a URL like this:

https://discord.com/api/oauth2/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=token&scope=guilds.join

Now when they authorize, the URL they got redirected to, specified as the redirect URI, will have a URL parameter that has the access token. You can use this with the discord.js function GuildMemberManager#add() , which works like this:

guild.members.add(userId, { accessToken: "ACCESS_TOKEN" })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM