Add GatewayIntent.none method with docs and tests

This commit is contained in:
Slipstream 2025-06-10 17:52:00 -06:00
parent 534b5b3980
commit 8b0e6fcce2
4 changed files with 21 additions and 2 deletions

View File

@ -49,6 +49,11 @@ class GatewayIntent(IntEnum):
AUTO_MODERATION_CONFIGURATION = 1 << 20
AUTO_MODERATION_EXECUTION = 1 << 21
@classmethod
def none(cls) -> int:
"""Return a bitmask representing no intents."""
return 0
@classmethod
def default(cls) -> int:
"""Returns default intents (excluding privileged ones like members, presences, message content)."""

View File

@ -16,3 +16,9 @@ bot = Client(
```
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.

View File

@ -0,0 +1,7 @@
import pytest
from disagreement.enums import GatewayIntent
def test_gateway_intent_none_equals_zero():
assert GatewayIntent.none() == 0

View File

@ -28,5 +28,6 @@ async def test_respond_modal(dummy_bot, interaction):
await interaction.respond_modal(modal)
dummy_bot._http.create_interaction_response.assert_called_once()
payload = dummy_bot._http.create_interaction_response.call_args.kwargs["payload"]
assert payload["type"] == InteractionCallbackType.MODAL.value
assert payload["data"]["custom_id"] == "m1"
data = payload.to_dict()
assert data["type"] == InteractionCallbackType.MODAL.value
assert data["data"]["custom_id"] == "m1"