I'm using javascript and i'm looking for how to get a list of flags (from public_flags) that a user has as an example:
[
"House Bravery",
"Partnered Server Owner",
"Early Verified Bot Developer"
]
I'm not using discord.js
CodePudding user response:
This works if you're trying to get them from a user object -
await user.fetchFlags().toArray() // would return an array as you require
CodePudding user response:
I found out how to achieve it with vanilla javascript:
var badges = [];
var flags = response.public_flags
flags = response.public_flags
if ((flags & badges2.Discord_Employee) == badges2.Discord_Employee) {
badges.push("Discord Employee")
}
if ((flags & badges2.Early_Supporter) == badges2.Early_Supporter) {
badges.push("Early Supporter")
}
if ((flags & badges2.House_Balance) == badges2.House_Balance) {
badges.push("House Balance")
}
if ((flags & badges2.House_Brilliance) == badges2.House_Brilliance) {
badges.push("House Brilliance")
}
if ((flags & badges2.House_Bravery) == badges2.House_Bravery) {
badges.push("House Bravery")
}
if ((flags & badges2.Bug_Hunter_Level_1) == badges2.Bug_Hunter_Level_1) {
badges.push("Bug Hunter LVL.1")
}
if ((flags & badges2.Bug_Hunter_Level_2) == badges2.Bug_Hunter_Level_2) {
badges.push("Bug Hunter LVL.2")
}
if ((flags & badges2.Early_Verified_Bot_Developer) == badges2.Early_Verified_Bot_Developer) {
badges.push("Verified Bot Dev")
}
if ((flags & badges2.HypeSquad_Events) == badges2.HypeSquad_Events) {
badges.push("HypeSquad Events")
}
if ((flags & badges2.Partnered_Server_Owner) == badges2.Partnered_Server_Owner) {
badges.push("Partnered Server Owner")
}