disagreement 0.2.0rc1__py3-none-any.whl → 0.4.0__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 +2 -4
- disagreement/audio.py +42 -5
- disagreement/cache.py +43 -4
- disagreement/caching.py +121 -0
- disagreement/client.py +1682 -1535
- disagreement/enums.py +10 -3
- disagreement/error_handler.py +5 -1
- disagreement/errors.py +1341 -3
- disagreement/event_dispatcher.py +3 -5
- disagreement/ext/__init__.py +1 -0
- disagreement/ext/app_commands/__init__.py +0 -2
- disagreement/ext/app_commands/commands.py +0 -2
- disagreement/ext/app_commands/context.py +0 -2
- disagreement/ext/app_commands/converters.py +2 -4
- disagreement/ext/app_commands/decorators.py +5 -7
- disagreement/ext/app_commands/handler.py +1 -3
- disagreement/ext/app_commands/hybrid.py +0 -2
- disagreement/ext/commands/__init__.py +63 -61
- disagreement/ext/commands/cog.py +0 -2
- disagreement/ext/commands/converters.py +16 -5
- disagreement/ext/commands/core.py +728 -563
- disagreement/ext/commands/decorators.py +294 -219
- disagreement/ext/commands/errors.py +0 -2
- disagreement/ext/commands/help.py +0 -2
- disagreement/ext/commands/view.py +1 -3
- disagreement/gateway.py +632 -586
- disagreement/http.py +1362 -1041
- disagreement/interactions.py +0 -2
- disagreement/models.py +2682 -2263
- disagreement/shard_manager.py +0 -2
- disagreement/ui/view.py +167 -165
- disagreement/voice_client.py +263 -162
- {disagreement-0.2.0rc1.dist-info → disagreement-0.4.0.dist-info}/METADATA +33 -6
- disagreement-0.4.0.dist-info/RECORD +55 -0
- disagreement-0.2.0rc1.dist-info/RECORD +0 -54
- {disagreement-0.2.0rc1.dist-info → disagreement-0.4.0.dist-info}/WHEEL +0 -0
- {disagreement-0.2.0rc1.dist-info → disagreement-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {disagreement-0.2.0rc1.dist-info → disagreement-0.4.0.dist-info}/top_level.txt +0 -0
disagreement/event_dispatcher.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# disagreement/event_dispatcher.py
|
2
|
-
|
3
1
|
"""
|
4
2
|
Event dispatcher for handling Discord Gateway events.
|
5
3
|
"""
|
@@ -76,7 +74,7 @@ class EventDispatcher:
|
|
76
74
|
"""Parses MESSAGE_DELETE and updates message cache."""
|
77
75
|
message_id = data.get("id")
|
78
76
|
if message_id:
|
79
|
-
self._client._messages.
|
77
|
+
self._client._messages.invalidate(message_id)
|
80
78
|
return data
|
81
79
|
|
82
80
|
def _parse_message_reaction_raw(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
@@ -124,7 +122,7 @@ class EventDispatcher:
|
|
124
122
|
"""Parses GUILD_MEMBER_ADD into a Member object."""
|
125
123
|
|
126
124
|
guild_id = str(data.get("guild_id"))
|
127
|
-
return self._client.parse_member(data, guild_id)
|
125
|
+
return self._client.parse_member(data, guild_id, just_joined=True)
|
128
126
|
|
129
127
|
def _parse_guild_member_remove(self, data: Dict[str, Any]):
|
130
128
|
"""Parses GUILD_MEMBER_REMOVE into a GuildMemberRemove model."""
|
@@ -198,7 +196,7 @@ class EventDispatcher:
|
|
198
196
|
try:
|
199
197
|
self._listeners[event_name_upper].remove(coro)
|
200
198
|
except ValueError:
|
201
|
-
pass
|
199
|
+
pass
|
202
200
|
|
203
201
|
def add_waiter(
|
204
202
|
self,
|
disagreement/ext/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# disagreement/ext/app_commands/converters.py
|
2
|
-
|
3
1
|
"""
|
4
2
|
Converters for transforming application command option values.
|
5
3
|
"""
|
@@ -466,8 +464,8 @@ async def run_converters(
|
|
466
464
|
|
467
465
|
# If no specific converter, and it's not a basic type match, raise error or return raw
|
468
466
|
# For now, let's raise if no converter found for a specific option type
|
469
|
-
if option_type in DEFAULT_CONVERTERS:
|
470
|
-
pass
|
467
|
+
if option_type in DEFAULT_CONVERTERS:
|
468
|
+
pass
|
471
469
|
|
472
470
|
# If it's a model type but no converter yet, this will need to be handled
|
473
471
|
# e.g. if param_type is User and option_type is ApplicationCommandOptionType.USER
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# disagreement/ext/app_commands/decorators.py
|
2
|
-
|
3
1
|
import inspect
|
4
2
|
import asyncio
|
5
3
|
from dataclasses import dataclass
|
@@ -134,7 +132,7 @@ def _extract_options_from_signature(
|
|
134
132
|
first_param = next(param_iter, None) # Consume 'self', get next
|
135
133
|
|
136
134
|
if first_param and first_param.name == "ctx": # Consume 'ctx'
|
137
|
-
pass
|
135
|
+
pass
|
138
136
|
elif (
|
139
137
|
first_param
|
140
138
|
): # If first_param was not 'self' and not 'ctx', it's a command option
|
@@ -147,7 +145,7 @@ def _extract_options_from_signature(
|
|
147
145
|
if param.kind == param.VAR_POSITIONAL or param.kind == param.VAR_KEYWORD:
|
148
146
|
# *args and **kwargs are not directly supported by slash command options structure.
|
149
147
|
# Could raise an error or ignore. For now, ignore.
|
150
|
-
|
148
|
+
|
151
149
|
continue
|
152
150
|
|
153
151
|
option_name = param.name
|
@@ -190,7 +188,7 @@ def _extract_options_from_signature(
|
|
190
188
|
# More complex Unions are not directly supported by a single option type.
|
191
189
|
# Could default to STRING or raise.
|
192
190
|
# For now, let's assume simple Optional[T] or direct types.
|
193
|
-
|
191
|
+
|
194
192
|
actual_type_for_mapping = str
|
195
193
|
|
196
194
|
elif origin is list and len(args) == 1:
|
@@ -198,7 +196,7 @@ def _extract_options_from_signature(
|
|
198
196
|
# via repeated options or specific component interactions, not directly in slash command options.
|
199
197
|
# This might indicate a need for a different interaction pattern or custom parsing.
|
200
198
|
# For now, treat List[str] as a string, others might error or default.
|
201
|
-
|
199
|
+
|
202
200
|
actual_type_for_mapping = args[
|
203
201
|
0
|
204
202
|
] # Use the inner type for mapping, but this is a simplification.
|
@@ -247,7 +245,7 @@ def _extract_options_from_signature(
|
|
247
245
|
|
248
246
|
if not option_type:
|
249
247
|
# Fallback or error if type couldn't be mapped
|
250
|
-
|
248
|
+
|
251
249
|
option_type = ApplicationCommandOptionType.STRING # Default fallback
|
252
250
|
|
253
251
|
required = (param.default == inspect.Parameter.empty) and not is_optional
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# disagreement/ext/app_commands/handler.py
|
2
|
-
|
3
1
|
import inspect
|
4
2
|
import json
|
5
3
|
import logging
|
@@ -341,7 +339,7 @@ class AppCommandHandler:
|
|
341
339
|
return value.lower() == "true"
|
342
340
|
return bool(value)
|
343
341
|
except (ValueError, TypeError):
|
344
|
-
pass
|
342
|
+
pass
|
345
343
|
return value # Return as is if no specific resolution or conversion applied
|
346
344
|
|
347
345
|
async def _resolve_value(
|
@@ -1,61 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
"""
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
)
|
22
|
-
from .errors import (
|
23
|
-
CommandError,
|
24
|
-
CommandNotFound,
|
25
|
-
BadArgument,
|
26
|
-
MissingRequiredArgument,
|
27
|
-
ArgumentParsingError,
|
28
|
-
CheckFailure,
|
29
|
-
CheckAnyFailure,
|
30
|
-
CommandOnCooldown,
|
31
|
-
CommandInvokeError,
|
32
|
-
MaxConcurrencyReached,
|
33
|
-
)
|
34
|
-
|
35
|
-
__all__ = [
|
36
|
-
# Cog
|
37
|
-
"Cog",
|
38
|
-
# Core
|
39
|
-
"Command",
|
40
|
-
"CommandContext",
|
41
|
-
# "CommandHandler", # Usually not part of public API for direct use by bot devs
|
42
|
-
# Decorators
|
43
|
-
"command",
|
44
|
-
"listener",
|
45
|
-
"check",
|
46
|
-
"check_any",
|
47
|
-
"cooldown",
|
48
|
-
"max_concurrency",
|
49
|
-
"requires_permissions",
|
50
|
-
|
51
|
-
"
|
52
|
-
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"
|
60
|
-
"
|
61
|
-
|
1
|
+
"""
|
2
|
+
disagreement.ext.commands - A command framework extension for the Disagreement library.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from .cog import Cog
|
6
|
+
from .core import (
|
7
|
+
Command,
|
8
|
+
CommandContext,
|
9
|
+
CommandHandler,
|
10
|
+
) # CommandHandler might be internal
|
11
|
+
from .decorators import (
|
12
|
+
command,
|
13
|
+
listener,
|
14
|
+
check,
|
15
|
+
check_any,
|
16
|
+
cooldown,
|
17
|
+
max_concurrency,
|
18
|
+
requires_permissions,
|
19
|
+
has_role,
|
20
|
+
has_any_role,
|
21
|
+
)
|
22
|
+
from .errors import (
|
23
|
+
CommandError,
|
24
|
+
CommandNotFound,
|
25
|
+
BadArgument,
|
26
|
+
MissingRequiredArgument,
|
27
|
+
ArgumentParsingError,
|
28
|
+
CheckFailure,
|
29
|
+
CheckAnyFailure,
|
30
|
+
CommandOnCooldown,
|
31
|
+
CommandInvokeError,
|
32
|
+
MaxConcurrencyReached,
|
33
|
+
)
|
34
|
+
|
35
|
+
__all__ = [
|
36
|
+
# Cog
|
37
|
+
"Cog",
|
38
|
+
# Core
|
39
|
+
"Command",
|
40
|
+
"CommandContext",
|
41
|
+
# "CommandHandler", # Usually not part of public API for direct use by bot devs
|
42
|
+
# Decorators
|
43
|
+
"command",
|
44
|
+
"listener",
|
45
|
+
"check",
|
46
|
+
"check_any",
|
47
|
+
"cooldown",
|
48
|
+
"max_concurrency",
|
49
|
+
"requires_permissions",
|
50
|
+
"has_role",
|
51
|
+
"has_any_role",
|
52
|
+
# Errors
|
53
|
+
"CommandError",
|
54
|
+
"CommandNotFound",
|
55
|
+
"BadArgument",
|
56
|
+
"MissingRequiredArgument",
|
57
|
+
"ArgumentParsingError",
|
58
|
+
"CheckFailure",
|
59
|
+
"CheckAnyFailure",
|
60
|
+
"CommandOnCooldown",
|
61
|
+
"CommandInvokeError",
|
62
|
+
"MaxConcurrencyReached",
|
63
|
+
]
|
disagreement/ext/commands/cog.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# pyright: reportIncompatibleMethodOverride=false
|
2
2
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Awaitable, Callable, TypeVar, Generic
|
4
4
|
from abc import ABC, abstractmethod
|
5
5
|
import re
|
6
|
+
import inspect
|
6
7
|
|
7
8
|
from .errors import BadArgument
|
8
9
|
from disagreement.models import Member, Guild, Role
|
@@ -36,6 +37,20 @@ class Converter(ABC, Generic[T]):
|
|
36
37
|
raise NotImplementedError("Converter subclass must implement convert method.")
|
37
38
|
|
38
39
|
|
40
|
+
class Greedy(list):
|
41
|
+
"""Type hint helper to greedily consume arguments."""
|
42
|
+
|
43
|
+
converter: Any = None
|
44
|
+
|
45
|
+
def __class_getitem__(cls, param: Any) -> type: # pyright: ignore[override]
|
46
|
+
if isinstance(param, tuple):
|
47
|
+
if len(param) != 1:
|
48
|
+
raise TypeError("Greedy[...] expects a single parameter")
|
49
|
+
param = param[0]
|
50
|
+
name = f"Greedy[{getattr(param, '__name__', str(param))}]"
|
51
|
+
return type(name, (Greedy,), {"converter": param})
|
52
|
+
|
53
|
+
|
39
54
|
# --- Built-in Type Converters ---
|
40
55
|
|
41
56
|
|
@@ -169,7 +184,3 @@ async def run_converters(ctx: "CommandContext", annotation: Any, argument: str)
|
|
169
184
|
raise BadArgument(f"No converter found for type annotation '{annotation}'.")
|
170
185
|
|
171
186
|
return argument # Default to string if no annotation or annotation is str
|
172
|
-
|
173
|
-
|
174
|
-
# Need to import inspect for the run_converters function
|
175
|
-
import inspect
|