Add GatewayIntent.none method with docs and tests
This commit is contained in:
parent
534b5b3980
commit
8b0e6fcce2
@ -49,6 +49,11 @@ class GatewayIntent(IntEnum):
|
|||||||
AUTO_MODERATION_CONFIGURATION = 1 << 20
|
AUTO_MODERATION_CONFIGURATION = 1 << 20
|
||||||
AUTO_MODERATION_EXECUTION = 1 << 21
|
AUTO_MODERATION_EXECUTION = 1 << 21
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def none(cls) -> int:
|
||||||
|
"""Return a bitmask representing no intents."""
|
||||||
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default(cls) -> int:
|
def default(cls) -> int:
|
||||||
"""Returns default intents (excluding privileged ones like members, presences, message content)."""
|
"""Returns default intents (excluding privileged ones like members, presences, message content)."""
|
||||||
|
@ -16,3 +16,9 @@ bot = Client(
|
|||||||
```
|
```
|
||||||
|
|
||||||
These values are passed to `GatewayClient` and applied whenever the connection needs to be re-established.
|
These values are passed to `GatewayClient` and applied whenever the connection needs to be re-established.
|
||||||
|
|
||||||
|
## Gateway Intents
|
||||||
|
|
||||||
|
`GatewayIntent` values control which events your bot receives from the Gateway. Use
|
||||||
|
`GatewayIntent.none()` to opt out of all events entirely. It returns `0`, which
|
||||||
|
represents a bitmask with no intents enabled.
|
||||||
|
7
tests/test_gateway_intent.py
Normal file
7
tests/test_gateway_intent.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from disagreement.enums import GatewayIntent
|
||||||
|
|
||||||
|
|
||||||
|
def test_gateway_intent_none_equals_zero():
|
||||||
|
assert GatewayIntent.none() == 0
|
@ -28,5 +28,6 @@ async def test_respond_modal(dummy_bot, interaction):
|
|||||||
await interaction.respond_modal(modal)
|
await interaction.respond_modal(modal)
|
||||||
dummy_bot._http.create_interaction_response.assert_called_once()
|
dummy_bot._http.create_interaction_response.assert_called_once()
|
||||||
payload = dummy_bot._http.create_interaction_response.call_args.kwargs["payload"]
|
payload = dummy_bot._http.create_interaction_response.call_args.kwargs["payload"]
|
||||||
assert payload["type"] == InteractionCallbackType.MODAL.value
|
data = payload.to_dict()
|
||||||
assert payload["data"]["custom_id"] == "m1"
|
assert data["type"] == InteractionCallbackType.MODAL.value
|
||||||
|
assert data["data"]["custom_id"] == "m1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user