aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
Diffstat (limited to 'discord')
-rw-r--r--discord/abc.py5
-rw-r--r--discord/ext/commands/flags.py10
-rw-r--r--discord/utils.py11
-rw-r--r--discord/webhook/async_.py13
-rw-r--r--discord/webhook/sync.py5
5 files changed, 20 insertions, 24 deletions
diff --git a/discord/abc.py b/discord/abc.py
index 36af70bd..c9e740f2 100644
--- a/discord/abc.py
+++ b/discord/abc.py
@@ -24,14 +24,13 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations
-import sys
import copy
import asyncio
from typing import TYPE_CHECKING, Protocol, runtime_checkable
from .iterators import HistoryIterator
from .context_managers import Typing
-from .enums import ChannelType, VideoQualityMode
+from .enums import ChannelType
from .errors import InvalidArgument, ClientException
from .mentions import AllowedMentions
from .permissions import PermissionOverwrite, Permissions
@@ -692,7 +691,7 @@ class GuildChannel(Protocol):
else:
raise InvalidArgument('target parameter must be either Member or Role')
- if isinstance(overwrite, _Undefined):
+ if overwrite is _undefined:
if len(permissions) == 0:
raise InvalidArgument('No overwrite provided.')
try:
diff --git a/discord/ext/commands/flags.py b/discord/ext/commands/flags.py
index 3aa9a65f..07c9cfc4 100644
--- a/discord/ext/commands/flags.py
+++ b/discord/ext/commands/flags.py
@@ -36,7 +36,7 @@ from discord.utils import resolve_annotation
from .view import StringView
from .converter import run_converters
-from discord.utils import maybe_coroutine
+from discord.utils import maybe_coroutine, MISSING
from dataclasses import dataclass, field
from typing import (
Dict,
@@ -69,14 +69,6 @@ if TYPE_CHECKING:
from .context import Context
-class _MissingSentinel:
- def __repr__(self):
- return 'MISSING'
-
-
-MISSING: Any = _MissingSentinel()
-
-
@dataclass
class Flag:
"""Represents a flag parameter for :class:`FlagConverter`.
diff --git a/discord/utils.py b/discord/utils.py
index d78c35a9..b2068ee5 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -79,6 +79,17 @@ __all__ = (
DISCORD_EPOCH = 1420070400000
+class _MissingSentinel:
+ def __eq__(self, other):
+ return False
+
+ def __repr__(self):
+ return '...'
+
+
+MISSING: Any = _MissingSentinel()
+
+
class _cached_property:
def __init__(self, function):
self.function = function
diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py
index 32552455..2a42b52b 100644
--- a/discord/webhook/async_.py
+++ b/discord/webhook/async_.py
@@ -28,7 +28,6 @@ import contextvars
import logging
import asyncio
import json
-import time
import re
from urllib.parse import quote as urlquote
@@ -67,16 +66,7 @@ if TYPE_CHECKING:
from ..abc import Snowflake
import datetime
-
-class _Missing:
- def __bool__(self):
- return False
-
- def __repr__(self):
- return '...'
-
-
-MISSING: Any = _Missing()
+MISSING = utils.MISSING
class AsyncDeferredLock:
@@ -731,6 +721,7 @@ class BaseWebhook(Hashable):
return Asset._from_default_avatar(self._state, 0)
return Asset._from_avatar(self._state, self.id, self._avatar)
+
class Webhook(BaseWebhook):
"""Represents an asynchronous Discord webhook.
diff --git a/discord/webhook/sync.py b/discord/webhook/sync.py
index 98bb528e..23445317 100644
--- a/discord/webhook/sync.py
+++ b/discord/webhook/sync.py
@@ -45,7 +45,7 @@ from ..message import Message
from ..http import Route
from ..object import Object
-from .async_ import BaseWebhook, handle_message_parameters, _WebhookState, MISSING
+from .async_ import BaseWebhook, handle_message_parameters, _WebhookState
__all__ = (
'SyncWebhook',
@@ -68,6 +68,8 @@ if TYPE_CHECKING:
except ModuleNotFoundError:
pass
+MISSING = utils.MISSING
+
class DeferredLock:
def __init__(self, lock: threading.Lock):
@@ -333,6 +335,7 @@ class WebhookAdapter:
route = Route('GET', '/webhooks/{webhook_id}/{webhook_token}', webhook_id=webhook_id, webhook_token=token)
return self.request(route, session=session)
+
_context = threading.local()
_context.adapter = WebhookAdapter()