ayako bot linked roles
hello ^^
i wanted to know how you made the ayako bot unauthorized for regular members like how it is in the ss, I've already made the app by following "Configuring App Metadata for Linked Roles" instructions on developer portal but everyone can authorize thru my bot, i want to set those type of linked roles for my server staff so i'd appreciate if someone helps me out here:AMSadCat:
13 Replies
When a user tries to verify their account through the linked roles, the website they are tryingto verify with is sent a user access code. You can use that access code to fetch the users ID and proceed from there.
Please ping me if you have further questions so I get the notification
do i have to follow this?
Yes
alrr so i am almost done with the url but i have two questions
-i made this bot on glitch.com becuz it was suggested in discord developer portal documentation named "Configuring App Metadata for Linked Roles" so am i supposed to paste it in the "discord.js" file in src/ category on glitch.com?
-i noticed theres a "state" thing in the url, but im not sure how to obtain its code or whatever it is 😭 could you tell me more about it?
For example:
https: //discord.com/oauth2/authorize?client_id=1083035700179509288&redirect_uri=https%3A%2F%2Fapi.ayakobot.com%2Flinked-roles%2Foauth-callback%3Ftype%3Downer&response_type=code&state=ad2e8d18-2db8-41ed-b605-f9274e9d74ec&scope=role_connections.write+identify&prompt=consenta
that underlined line, where do i get that code
sry for the trouble, im new to this :AMohnocat:
Discord provides you with a Demo Project on Glitch and Source Code on GitHub
I used Glitch for my original attempt, you can find references and information there
In the src/discord.js file on line 21 you can see "state" being generated by
crypto.randomUUID()
and getting set to the request's response
The state is checked by your app once the user comes back from Authenticating your application (see src/server.js line 53 to 60)i seee, am i supposed to change the url in 23 line in src/ discord.js file ?
nope, that request is going to discord
all of them are fine
you just adjust the urls in your developer portal
do i add the authorization url mentioned in the documentation here (in the default auth link)?
should it look exactly the same but replace the client id and redirect uri with my own? @Larsuzzee
url in the image i replied to:
https: //discord.com/oauth2/authorize?response_type=code&client_id=157730590492196864&scope=identify%20guilds.join&state=15773059ghq9183habn&redirect_uri=https%3A%2F%2Fnicememe.website&prompt=consent
in the redirects you put the
https://your-glitch-subdomain.glitch.me/discord-oauth-callback
and in the "Verified Roles Verification URL" you puthttps://your-glitch-subdomain.glitch.me/linked-role
(assuming you do this through glitch)i already have those setup
but how do i make it so only specific users are able to authorize and get the linked roles because rn everyone can get the roles
:AMWowww:
in server.js on line 66 you can receive the user ID of whoever is trying to verify
if the user id doesnt match what you were expecting, simply do
res.sendStatus(403)
and return
for more questions please use https://discord.gg/discord-api or https://discord.gg/discord-developers