Is it possible to check if a player has a roblox badge from discord?

If it is possible to check it, how would you do it, would you need an external website or something?

1 Like

Im guessing you have to use https Service, you can read about it there.

1 Like

You wouldn’t need an external website, you can just use Roblox’s APIs. In this case, you will use the badge API. In my opinion, using the /v1/users/{userId}/badges/awarded-dates to get the award date of the badge is easier than going through multiple pages using the /v1/users/{userId}/badges, so I will use the award date one.

here’s a version for axios:

const userId = 1
let badgeIds = "1,2"

async function checkbadge() {
    known = await axios.get(`https://badges.roblox.com/v1/users/${userId}/badges/awarded-dates?badgeIds=${Ids}`)
    .catch((err) => console.log(err))
    
    if(known.data.data.length > 0) {
        console.log("Owns badge")
    } else {
        console.log("Doesn't own")
    }
}

checkbadge()

and this is one using https:

const userId = 1
let badgeIds = "1,2"

https.get(`https://badges.roblox.com/v1/users/${userId}/badges/awarded-dates?badgeIds=${badgeIds}`, (res) => {
    let data = ""
    
    res.on("data", d => {
        data += d
    })
    
    res.on("end", () => {
        if(JSON.parse(data).data.length > 0) {
            console.log("Owns badge")
        } else {
            console.log("Doesn't own")
        }
    })
})
1 Like
async function a() {
    return b
}

console.log(a())

Not relevant to this post, but you can do ```javascript <code>``` to display JavaScript highlighted syntax code. You can do this for other languages by replacing javascript, doesn’t support every language out there though.

Oh, I never knew that, thank you!

1 Like

How would I get the userID from javascript? Would I get it from roblox studio?