disagreement 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- disagreement/__init__.py +36 -0
- disagreement/cache.py +55 -0
- disagreement/client.py +1144 -0
- disagreement/components.py +166 -0
- disagreement/enums.py +357 -0
- disagreement/error_handler.py +33 -0
- disagreement/errors.py +112 -0
- disagreement/event_dispatcher.py +243 -0
- disagreement/gateway.py +490 -0
- disagreement/http.py +657 -0
- disagreement/hybrid_context.py +32 -0
- disagreement/i18n.py +22 -0
- disagreement/interactions.py +572 -0
- disagreement/logging_config.py +26 -0
- disagreement/models.py +1642 -0
- disagreement/oauth.py +109 -0
- disagreement/permissions.py +99 -0
- disagreement/rate_limiter.py +75 -0
- disagreement/shard_manager.py +65 -0
- disagreement/typing.py +42 -0
- disagreement/ui/__init__.py +17 -0
- disagreement/ui/button.py +99 -0
- disagreement/ui/item.py +38 -0
- disagreement/ui/modal.py +132 -0
- disagreement/ui/select.py +92 -0
- disagreement/ui/view.py +165 -0
- disagreement/voice_client.py +120 -0
- disagreement-0.0.1.dist-info/METADATA +163 -0
- disagreement-0.0.1.dist-info/RECORD +32 -0
- disagreement-0.0.1.dist-info/WHEEL +5 -0
- disagreement-0.0.1.dist-info/licenses/LICENSE +26 -0
- disagreement-0.0.1.dist-info/top_level.txt +1 -0
disagreement/__init__.py
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# disagreement/__init__.py
|
2
|
+
|
3
|
+
"""
|
4
|
+
Disagreement
|
5
|
+
~~~~~~~~~~~~
|
6
|
+
|
7
|
+
A Python library for interacting with the Discord API.
|
8
|
+
|
9
|
+
:copyright: (c) 2025 Slipstream
|
10
|
+
:license: BSD 3-Clause License, see LICENSE for more details.
|
11
|
+
"""
|
12
|
+
|
13
|
+
__title__ = "disagreement"
|
14
|
+
__author__ = "Slipstream"
|
15
|
+
__license__ = "BSD 3-Clause License"
|
16
|
+
__copyright__ = "Copyright 2025 Slipstream"
|
17
|
+
__version__ = "0.0.1"
|
18
|
+
|
19
|
+
from .client import Client
|
20
|
+
from .models import Message, User
|
21
|
+
from .voice_client import VoiceClient
|
22
|
+
from .typing import Typing
|
23
|
+
from .errors import (
|
24
|
+
DisagreementException,
|
25
|
+
HTTPException,
|
26
|
+
GatewayException,
|
27
|
+
AuthenticationError,
|
28
|
+
)
|
29
|
+
from .enums import GatewayIntent, GatewayOpcode # Export enums
|
30
|
+
from .error_handler import setup_global_error_handler
|
31
|
+
from .hybrid_context import HybridContext
|
32
|
+
from .ext import tasks
|
33
|
+
|
34
|
+
# Set up logging if desired
|
35
|
+
# import logging
|
36
|
+
# logging.getLogger(__name__).addHandler(logging.NullHandler())
|
disagreement/cache.py
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import time
|
4
|
+
from typing import TYPE_CHECKING, Dict, Generic, Optional, TypeVar
|
5
|
+
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from .models import Channel, Guild
|
8
|
+
|
9
|
+
T = TypeVar("T")
|
10
|
+
|
11
|
+
|
12
|
+
class Cache(Generic[T]):
|
13
|
+
"""Simple in-memory cache with optional TTL support."""
|
14
|
+
|
15
|
+
def __init__(self, ttl: Optional[float] = None) -> None:
|
16
|
+
self.ttl = ttl
|
17
|
+
self._data: Dict[str, tuple[T, Optional[float]]] = {}
|
18
|
+
|
19
|
+
def set(self, key: str, value: T) -> None:
|
20
|
+
expiry = time.monotonic() + self.ttl if self.ttl is not None else None
|
21
|
+
self._data[key] = (value, expiry)
|
22
|
+
|
23
|
+
def get(self, key: str) -> Optional[T]:
|
24
|
+
item = self._data.get(key)
|
25
|
+
if not item:
|
26
|
+
return None
|
27
|
+
value, expiry = item
|
28
|
+
if expiry is not None and expiry < time.monotonic():
|
29
|
+
self.invalidate(key)
|
30
|
+
return None
|
31
|
+
return value
|
32
|
+
|
33
|
+
def invalidate(self, key: str) -> None:
|
34
|
+
self._data.pop(key, None)
|
35
|
+
|
36
|
+
def clear(self) -> None:
|
37
|
+
self._data.clear()
|
38
|
+
|
39
|
+
def values(self) -> list[T]:
|
40
|
+
now = time.monotonic()
|
41
|
+
items = []
|
42
|
+
for key, (value, expiry) in list(self._data.items()):
|
43
|
+
if expiry is not None and expiry < now:
|
44
|
+
self.invalidate(key)
|
45
|
+
else:
|
46
|
+
items.append(value)
|
47
|
+
return items
|
48
|
+
|
49
|
+
|
50
|
+
class GuildCache(Cache["Guild"]):
|
51
|
+
"""Cache specifically for :class:`Guild` objects."""
|
52
|
+
|
53
|
+
|
54
|
+
class ChannelCache(Cache["Channel"]):
|
55
|
+
"""Cache specifically for :class:`Channel` objects."""
|