fix(structures): correctly check if flags are present (#11404)

* fix(structures): correctly check if flags are present

* chore: isFieldSet type guard

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Qjuh
2026-01-27 17:47:56 +01:00
committed by GitHub
parent 323d8e7571
commit 7a7fecbe3c
4 changed files with 41 additions and 9 deletions

View File

@@ -4,7 +4,7 @@ import { Structure } from '../Structure.js';
import { MessageFlagsBitField } from '../bitfields/MessageFlagsBitField.js';
import { dateToDiscordISOTimestamp } from '../utils/optimization.js';
import { kData, kEditedTimestamp } from '../utils/symbols.js';
import { isIdSet } from '../utils/type-guards.js';
import { isFieldSet, isIdSet } from '../utils/type-guards.js';
import type { Partialize } from '../utils/types.js';
// TODO: missing substructures: application
@@ -110,8 +110,9 @@ export class Message<Omitted extends keyof APIMessage | '' = 'edited_timestamp'
* The flags of this message as a bit field
*/
public get flags() {
const flags = this[kData].flags;
return flags ? new MessageFlagsBitField(this[kData].flags as MessageFlags) : null;
return isFieldSet(this[kData], 'flags', 'number')
? new MessageFlagsBitField(this[kData].flags as MessageFlags)
: null;
}
/**