Discord API - 使用 public_flags 获取用户徽章
Discord API - Get user's badges using public_flags
我正在使用 javascript,我正在寻找如何获取用户拥有的标志列表(来自 public_flags)作为示例:
[
"House Bravery",
"Partnered Server Owner",
"Early Verified Bot Developer"
]
我没有使用 discord.js
如果您试图从用户对象中获取它们,这会起作用 -
await user.fetchFlags().toArray() // would return an array as you require
我发现了如何用原版实现它 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")
}
我正在使用 javascript,我正在寻找如何获取用户拥有的标志列表(来自 public_flags)作为示例:
[
"House Bravery",
"Partnered Server Owner",
"Early Verified Bot Developer"
]
我没有使用 discord.js
如果您试图从用户对象中获取它们,这会起作用 -
await user.fetchFlags().toArray() // would return an array as you require
我发现了如何用原版实现它 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")
}