BitField¶
Extends: None
Data structure that makes it easier to intract with a bitfield
Description¶
A base data structure which defines a bitfield to implement flags and permissions for Discord.
Properties¶
Type | Name | Description |
---|---|---|
int | bitfield | The bitfield of the packed bits |
Dictionary | FLAGS | Numeric bitfield flags (Defined in extension class) |
Methods¶
Returns | Definition |
---|---|
Bitfield | add(bit) |
bool | any(bit) |
bool | equals(bit) |
bool | has(bit) |
Array | missing(bit) |
Bitfield | remove(bit) |
Dictionary | serialize() |
Array | to_array() |
int | resolve(bit) |
Method Descriptions¶
add(bit)¶
Adds bit to these ones.
Returns: BitField
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to add |
Here the bit is any data that can be resolved to give a bitfield. This can be: - A bit number - A string flag of the bitfield - An instance of BitField
- An Array of data that can be resolved to give a bitfield
any(bit)¶
Checks whether the bitfield has a bit, or any of multiple bits.
Returns: bool
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to check for |
equals(bit)¶
Checks if this bitfield equals another.
Returns: bool
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to check for |
has(bit)¶
Checks whether the bitfield has a bit, or multiple bits.
Returns: bool
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to check for |
missing(bit)¶
Returns all given bits that are missing from the bitfield.
Returns: Array
Note
Implemented by the children classes.
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to check for |
remove(bit)¶
Removes bits from these.
Returns: BitField
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to check for |
serialize()¶
Returns a dictionary mapping flag names to a boolean indicating whether the bit is available.
Returns: Dictionary
to_array()¶
Returns an Array of flag names based on the bits available.
Returns: Array
resolve(bit)¶
Resolves bitfields to their numeric form.
Returns: int
Type | Parameter | Description |
---|---|---|
Variant | bit | The bit(s) to resolve |