Skip to content

Commit 9a7c00d

Browse files
Fix verified bot checkmark by using public_flags
Well what’s the difference between User.public_flags and User.flags? Discord docs says it’s the same in one issue but sometimes one of them is nil…
1 parent cc15607 commit 9a7c00d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Swiftcord/Views/Message/MessageView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import DiscordKitCommon
1212
import DiscordKitCore
1313

1414
struct NonUserBadge: View {
15-
let flags: Int?
15+
let flags: User.Flags?
1616
let isWebhook: Bool
1717

1818
var body: some View {
1919
HStack(spacing: 0) {
20-
if let flags = flags, flags & 65536 != 0 {
20+
if let flags = flags, flags.contains(.verifiedBot) {
2121
Image(systemName: "checkmark")
2222
.font(.system(size: 8, weight: .heavy))
2323
.frame(width: 15)
@@ -84,8 +84,10 @@ struct MessageView: View {
8484
.font(.system(size: 15))
8585
.fontWeight(.medium)
8686
if message.author.bot ?? false || message.webhook_id != nil {
87+
// No idea what's the difference between flags and public_flags,
88+
// just try both to see which is present
8789
NonUserBadge(
88-
flags: message.author.flags?.rawValue,
90+
flags: message.author.flags ?? message.author.public_flags,
8991
isWebhook: message.webhook_id != nil
9092
)
9193
}

Swiftcord/Views/Message/ReferenceMessageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct ReferenceMessageView: View {
4040

4141
if quotedMsg.author?.bot == true || quotedMsg.webhook_id != nil {
4242
NonUserBadge(
43-
flags: quotedMsg.author?.flags?.rawValue,
43+
flags: quotedMsg.author?.public_flags,
4444
isWebhook: quotedMsg.webhook_id != nil
4545
)
4646
}

Swiftcord/Views/User/Profile/MiniUserProfileView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct MiniUserProfileView: View {
7777
.foregroundColor(.primary.opacity(0.7))
7878
}.font(.title2).lineLimit(1)
7979
if user.bot == true || isWebhook {
80-
NonUserBadge(flags: user.flags?.rawValue, isWebhook: isWebhook)
80+
NonUserBadge(flags: user.public_flags, isWebhook: isWebhook)
8181
}
8282
Spacer()
8383
}

0 commit comments

Comments
 (0)