Skip to content

feat: Viewless components #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 106 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
17766df
Move utils.py to utils/
Paillat-dev May 29, 2025
195e2a0
:fire: Remove `filter_params`
Paillat-dev May 29, 2025
fafa149
:recycle: Merge `time_snowflake` and `generate_snowflake`, move `basi…
Paillat-dev May 29, 2025
e2d8eb1
:recycle: Merge `time_snowflake` and `generate_snowflake`, move `basi…
Paillat-dev May 29, 2025
86bd168
:fire: Remove `utils.sleep_until`
Paillat-dev May 29, 2025
23c2c49
chore: Start migration to uv & ruff & hatch (#4)
Paillat-dev May 29, 2025
97ccda5
Setup CHANGELOG.md (#6)
Paillat-dev May 29, 2025
a5b70e6
fix: Role Edit TypeHint (#2795)
Lumabots May 30, 2025
f2a4eb6
chore: update docs workflows to use 'uv' for dependency management (#33)
Paillat-dev May 30, 2025
e391c82
fix: command syncing edge cases (#2797)
NeloBlivion May 31, 2025
40e20c0
:fire: Move stuff to private
Paillat-dev May 31, 2025
6e5ccb5
Merge branch 'master' into refactor-utils
Paillat-dev May 31, 2025
cd1531d
fix: VoiceClient crashes while receiving audio (#2800)
Hema2-official Jun 3, 2025
1575a27
chore(deps): bump typing-extensions from 4.13.1 to 4.13.2 in the patc…
dependabot[bot] Jun 4, 2025
509569b
feat: add created_at property to Interaction (#2801)
Lumabots Jun 4, 2025
f944b25
chore(deps): update setuptools requirement from <=78.1.0,>=62.6 to >=…
dependabot[bot] Jun 4, 2025
acf0c7a
chore!: :fire: Remove deprecated support for Option in bridge command…
Paillat-dev Jun 4, 2025
7efe9a2
fix: :bug: `TypeError` when specifying `thread_name` in Webhook.send …
Paillat-dev Jun 4, 2025
aeacfed
fix: add BanEntry to __all__ exports in guild.py (#2798)
Lumabots Jun 4, 2025
0571244
fix: correct generic return type in component utils (#2796)
Lumabots Jun 4, 2025
5ddd1e2
chore(deps): update setuptools-scm requirement from <=8.2.1,>=6.2 to …
dependabot[bot] Jun 4, 2025
0618653
chore(deps-dev): update pylint requirement from ~=3.3.6 to ~=3.3.7 (#…
dependabot[bot] Jun 4, 2025
2377245
chore(pre-commit): pre-commit autoupdate (#2792)
pre-commit-ci[bot] Jun 4, 2025
5eaebfb
docs: :memo: Fix malformed CHANGELOG.md hyperlinks (#2804)
Paillat-dev Jun 5, 2025
ad3d2a8
fix: :bug: Fix `ValueError` when using `Flag` (#2759)
Paillat-dev Jun 5, 2025
f17fedd
ci(deps): bump crowdin/github-action from 2.7.0 to 2.7.1 in the patch…
dependabot[bot] Jun 5, 2025
8e97cb5
fix: resolve regex library warnings (#2807)
emmanuel-ferdman Jun 6, 2025
735673b
fix: support emoji aliases like `:smile:` in PartialEmoji.from_str (#…
Lumabots Jun 20, 2025
8619b69
Revert "fix: support emoji aliases like `:smile:` in PartialEmoji.fro…
Lulalaby Jun 20, 2025
1da5de0
:refactor: move parse_time function to private utils and update refer…
Paillat-dev Jun 24, 2025
88180b2
:memo: update CHANGELOG to reflect utility function changes
Paillat-dev Jun 24, 2025
b5c8a58
:art: Format
Paillat-dev Jun 24, 2025
0cdcb31
:recycle: move deprecation utilities to private utils and update refe…
Paillat-dev Jun 24, 2025
09a11a9
:recycle: move snowflake_time function to public.py
Paillat-dev Jun 24, 2025
4a2753c
:recycle: move oauth_url and Undefined class to public.py; update imp…
Paillat-dev Jun 24, 2025
ca89539
Merge branch 'master' into refactor-utils
Paillat-dev Jun 24, 2025
1cf53ab
:memo: remove deprecated utility functions from documentation
Paillat-dev Jun 24, 2025
2ac8152
:memo: remove (re)moved utility functions from documentation
Paillat-dev Jun 24, 2025
24a367c
:memo: add utils.resolve_template to changelog and remove from docume…
Paillat-dev Jun 24, 2025
0c6270a
:bug: fix import path for warn_deprecated utility function
Paillat-dev Jun 24, 2025
84ff9df
:refactor: reorganize utility function imports and move evaluate_anno…
Paillat-dev Jun 24, 2025
8474f05
:recycle: update import paths for utility functions to use relative i…
Paillat-dev Jun 24, 2025
1c65fc8
chore: :memo: update license format in pyproject.toml (#2824)
Paillat-dev Jul 7, 2025
c8ddcb5
:recycle: move delay_task function to private
Paillat-dev Jul 7, 2025
8a02d54
:recycle: removed `utils.get` in favor of `utils.find`
Paillat-dev Jul 7, 2025
39aef0f
:recycle: removed `utils._unique`
Paillat-dev Jul 7, 2025
6b0379c
:recycle: move `async_all` to private
Paillat-dev Jul 7, 2025
cc8f27f
:recycle: move `maybe_coroutine` to private
Paillat-dev Jul 7, 2025
1d70dec
:recycle: rename `maybe_coroutine` to `maybe_awaitable`
Paillat-dev Jul 7, 2025
b2b8625
:recycle: move `sane_wait_for` to private
Paillat-dev Jul 7, 2025
d0a094d
:recycle: move `format_dt` to public
Paillat-dev Jul 7, 2025
fb554fd
:recycle: remove `as_chunks` function
Paillat-dev Jul 7, 2025
1a551cb
:memo: update `utils.sleep_until` and `utils.parse_time` changelog to…
Paillat-dev Jul 7, 2025
295ed46
:recycle: move `compute_timedelta` function
Paillat-dev Jul 7, 2025
4afe54a
:recycle: move `valid_icon_size` to `asset.py`
Paillat-dev Jul 7, 2025
a021450
:recycle: refactor `utils.get` to `utils.find` across multiple files
Paillat-dev Jul 7, 2025
c6f7914
:recycle: refactor markdown and mention handling functions in `__init…
Paillat-dev Jul 7, 2025
c29cdc2
:recycle: move SnowflakeList to `private.py`
Paillat-dev Jul 7, 2025
6c57d5e
:recycle: move `find` function from `__init__.py` to `public.py`
Paillat-dev Jul 7, 2025
d079c7c
:recycle: move `copy_doc` to private
Paillat-dev Jul 7, 2025
611c7c7
:recycle: refactor `get` to `find` in onboarding and sticker modules
Paillat-dev Jul 7, 2025
cd4e436
:bug: fix `copy_doc` decorator usage in context.py
Paillat-dev Jul 7, 2025
ad777e4
Merge branch 'master' into refactor-utils
Paillat-dev Jul 7, 2025
aec45a2
:recycle: move SequenceProxy to private module
Paillat-dev Jul 7, 2025
9755fe8
:recycle: move cached_slot_property to private
Paillat-dev Jul 7, 2025
006a7f8
:rotating_light: add noqa comments to prevent linting errors
Paillat-dev Jul 7, 2025
d5263c7
:recycle: move get_slots function to private module
Paillat-dev Jul 7, 2025
44f753e
:recycle: refactor JSON serialization functions to private module
Paillat-dev Jul 7, 2025
c961e36
:recycle: replace custom cached_property implementation with functool…
Paillat-dev Jul 7, 2025
a4bda5f
:pencil2: fix typo in CHANGELOG-V3.md
Paillat-dev Jul 7, 2025
b81d2d5
:heavy_minus_sign: remove unused dependencies from pyproject.toml and…
Paillat-dev Jul 7, 2025
a84e06d
:coffin: remove test.py
Paillat-dev Jul 7, 2025
330161c
:recycle: remove duplicate import of raw_mentions in __init__.py
Paillat-dev Jul 7, 2025
b3f919e
:bug: fix raw_role_mentions import in utils/__init__.py
Paillat-dev Jul 8, 2025
450140d
chore(pre-commit): pre-commit autoupdate (#2829)
pre-commit-ci[bot] Jul 21, 2025
5a23100
chore(deps-dev): update coverage requirement from ~=7.8 to ~=7.9 (#2811)
dependabot[bot] Jul 21, 2025
1214a70
docs: :memo: Fix malformed hyperlink in CHANGELOG.md number 2 (#2806)
Paillat-dev Jul 21, 2025
b44e13f
chore(deps-dev): update pytest requirement from ~=8.3.5 to ~=8.4.0 (#…
dependabot[bot] Jul 21, 2025
a5aa21f
feat: components v2 & `View` improvements (#2707)
NeloBlivion Jul 21, 2025
2ae01b7
fix: 4006 voice crashes and upgrade to voice v8 (#2812)
DA-344 Jul 25, 2025
fce3fc1
ci(deps): bump crowdin/github-action from 2.7.1 to 2.8.0 in the minor…
dependabot[bot] Jul 27, 2025
268d71e
Merge remote-tracking branch 'pycord/master' into viewless-components
Paillat-dev Jul 29, 2025
e075e1f
WIP
Paillat-dev Jul 31, 2025
0011382
WIP
Paillat-dev Aug 3, 2025
0c9272d
:fire: Duplicate `Iterable` import
Paillat-dev Aug 4, 2025
2b981dd
Apply suggestion from @Lumabots
Paillat-dev Aug 4, 2025
488c4de
Merge branch 'master' into refactor-utils
Paillat-dev Aug 4, 2025
7053daf
Merge branch 'master' into viewless-components
Paillat-dev Aug 6, 2025
6a27770
WIP
Paillat-dev Aug 6, 2025
df155d6
:fire: Simplify imports
Paillat-dev Aug 6, 2025
7d92da0
:fire: Simplify imports number 2
Paillat-dev Aug 6, 2025
856853f
:fire: Simplify imports number 3 omg this is amazing
Paillat-dev Aug 6, 2025
e32ba97
:fire: Simplify imports number 4 omg this is amazing yee
Paillat-dev Aug 6, 2025
d1be746
:fire: Simplify imports number 5
Paillat-dev Aug 6, 2025
bd59784
Update discord/ext/commands/converter.py
Paillat-dev Aug 6, 2025
34d5fde
Apply suggestions from code review
Paillat-dev Aug 6, 2025
5ef78ca
Update discord/state.py
Paillat-dev Aug 6, 2025
0acef26
Update discord/state.py
Paillat-dev Aug 6, 2025
c7db59c
:recycle: Remove _ prefix in from and to json
Paillat-dev Aug 6, 2025
0ca346d
:recycle: Make import less weird
Paillat-dev Aug 6, 2025
fc2beaa
Merge branch 'refactor-utils' into viewless-components
Paillat-dev Aug 7, 2025
8a47e6a
Progress
Paillat-dev Aug 7, 2025
571a522
WIP
Paillat-dev Aug 7, 2025
8ae7503
WIP 2
Paillat-dev Aug 7, 2025
192f6b6
Some more work
Paillat-dev Aug 9, 2025
979b860
Wow so this is starting to look like something
Paillat-dev Aug 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs-localization-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
working-directory: ./docs
- name: "Crowdin"
id: crowdin
uses: crowdin/github-action@v2.7.1
uses: crowdin/github-action@v2.9.0
with:
upload_sources: false
upload_translations: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-localization-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
sphinx-intl update -p ./build/locales ${{ vars.SPHINX_LANGUAGES }}
working-directory: ./docs
- name: "Crowdin"
uses: crowdin/github-action@v2.7.1
uses: crowdin/github-action@v2.9.0
with:
upload_sources: true
upload_translations: false
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: end-of-file-fixer
exclude: \.(po|pot|yml|yaml)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.9
rev: v0.12.0
hooks:
- id: ruff
args: [ --fix ]
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG-V3.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,17 @@ release.
### Deprecated

### Removed

- `utils.filter_params`
- `utils.sleep_until` use `asyncio.sleep` combined with `datetime.datetime` instead
- `utils.compute_timedelta` use the `datetime` module instead
- `utils.resolve_invite`
- `utils.resolve_template`
- `utils.parse_time` use `datetime.datetime.fromisoformat` instead
- `utils.time_snowflake` use `utils.generate_snowflake` instead
- `utils.warn_deprecated`
- `utils.deprecated`
- `utils.get` use `utils.find` with `lambda i: i.attr == val` instead
- `AsyncIterator.get` use `AsyncIterator.find` with `lambda i: i.attr == val` instead
- `utils.as_chunks` use `itertools.batched` on Python 3.12+ or your own implementation
instead
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2781](https://github.com/Pycord-Development/pycord/pull/2781))
- Fixed `VoiceClient` crashing randomly while receiving audio
([#2800](https://github.com/Pycord-Development/pycord/pull/2800))
- Fixed `VoiceClient.connect` failing to do initial connection.
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))

### Changed

Expand All @@ -138,6 +140,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
- Changed the default value of `ApplicationCommand.nsfw` to `False`.
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
- Upgraded voice websocket version to v8.
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))

### Deprecated

Expand All @@ -150,8 +154,8 @@ These changes are available on the `master` branch, but have not yet been releas

### Removed

- Removed deprecated support for `Option` in `BridgeCommand`. Use `BridgeOption`
instead. ([#2731])(https://github.com/Pycord-Development/pycord/pull/2731))
- Removed deprecated support for `Option` in `BridgeCommand`, use `BridgeOption`
instead. ([#2731](https://github.com/Pycord-Development/pycord/pull/2731))

## [2.6.1] - 2024-09-15

Expand Down
2 changes: 1 addition & 1 deletion discord/__version.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from typing import Literal, NamedTuple

from .utils import deprecated
from .utils.private import deprecated
from ._version import __version__, __version_tuple__


Expand Down
13 changes: 10 additions & 3 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
runtime_checkable,
)

from .utils.private import warn_deprecated
from . import utils
from .context_managers import Typing
from .enums import ChannelType
Expand Down Expand Up @@ -724,7 +725,7 @@ def permissions_for(self, obj: Member | Role, /) -> Permissions:
if obj.is_default():
return base

overwrite = utils.get(self._overwrites, type=_Overwrites.ROLE, id=obj.id)
overwrite = utils.find(lambda o: o.type == _Overwrites.ROLE and o.id == obj.id, self._overwrites)
if overwrite is not None:
base.handle_overwrite(overwrite.allow, overwrite.deny)

Expand Down Expand Up @@ -1529,7 +1530,7 @@ async def send(
from .message import MessageReference # noqa: PLC0415

if not isinstance(reference, MessageReference):
utils.warn_deprecated(
warn_deprecated(
f"Passing {type(reference).__name__} to reference",
"MessageReference",
"2.7",
Expand All @@ -1545,6 +1546,10 @@ async def send(
raise InvalidArgument(f"view parameter must be View not {view.__class__!r}")

components = view.to_components()
if view.is_components_v2():
if embeds or content:
raise TypeError("cannot send embeds or content with a view using v2 component logic")
flags.is_components_v2 = True
else:
components = None

Expand Down Expand Up @@ -1605,8 +1610,10 @@ async def send(

ret = state.create_message(channel=channel, data=data)
if view:
state.store_view(view, ret.id)
if view.is_dispatchable():
state.store_view(view, ret.id)
view.message = ret
view.refresh(ret.components)

if delete_after is not None:
await ret.delete(delay=delete_after)
Expand Down
4 changes: 2 additions & 2 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .colour import Colour
from .enums import ActivityType, try_enum
from .partial_emoji import PartialEmoji
from .utils import _get_as_snowflake
from .utils.private import get_as_snowflake

__all__ = (
"BaseActivity",
Expand Down Expand Up @@ -226,7 +226,7 @@ def __init__(self, **kwargs):
self.timestamps: ActivityTimestamps = kwargs.pop("timestamps", {})
self.assets: ActivityAssets = kwargs.pop("assets", {})
self.party: ActivityParty = kwargs.pop("party", {})
self.application_id: int | None = _get_as_snowflake(kwargs, "application_id")
self.application_id: int | None = get_as_snowflake(kwargs, "application_id")
self.url: str | None = kwargs.pop("url", None)
self.flags: int = kwargs.pop("flags", 0)
self.sync_id: str | None = kwargs.pop("sync_id", None)
Expand Down
7 changes: 4 additions & 3 deletions discord/appinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from typing import TYPE_CHECKING

from .utils.private import warn_deprecated, get_as_snowflake
from . import utils
from .asset import Asset
from .permissions import Permissions
Expand Down Expand Up @@ -200,9 +201,9 @@ def __init__(self, state: ConnectionState, data: AppInfoPayload):
self._summary: str = data["summary"]
self.verify_key: str = data["verify_key"]

self.guild_id: int | None = utils._get_as_snowflake(data, "guild_id")
self.guild_id: int | None = get_as_snowflake(data, "guild_id")

self.primary_sku_id: int | None = utils._get_as_snowflake(data, "primary_sku_id")
self.primary_sku_id: int | None = get_as_snowflake(data, "primary_sku_id")
self.slug: str | None = data.get("slug")
self._cover_image: str | None = data.get("cover_image")
self.terms_of_service_url: str | None = data.get("terms_of_service_url")
Expand Down Expand Up @@ -261,7 +262,7 @@ def summary(self) -> str | None:
.. versionadded:: 1.3
.. deprecated:: 2.7
"""
utils.warn_deprecated(
warn_deprecated(
"summary",
"description",
reference="https://discord.com/developers/docs/resources/application#application-object-application-structure",
Expand Down
9 changes: 7 additions & 2 deletions discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
MISSING = utils.MISSING


def _valid_icon_size(size: int) -> bool:
"""Icons must be power of 2 within [16, 4096]."""
return not size & (size - 1) and 4096 >= size >= 16


class AssetMixin:
url: str
_state: Any | None
Expand Down Expand Up @@ -371,7 +376,7 @@ def replace(
url = url.with_path(f"{path}.{static_format}")

if size is not MISSING:
if not utils.valid_icon_size(size):
if not _valid_icon_size(size):
raise InvalidArgument("size must be a power of 2 between 16 and 4096")
url = url.with_query(size=size)
else:
Expand All @@ -398,7 +403,7 @@ def with_size(self, size: int, /) -> Asset:
InvalidArgument
The asset had an invalid size.
"""
if not utils.valid_icon_size(size):
if not _valid_icon_size(size):
raise InvalidArgument("size must be a power of 2 between 16 and 4096")

url = str(yarl.URL(self._url).with_query(size=size))
Expand Down
18 changes: 10 additions & 8 deletions discord/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generator, TypeVar
from functools import cached_property

from .utils.private import get_as_snowflake
from . import enums, utils
from .asset import Asset
from .automod import AutoModAction, AutoModTriggerMetadata
Expand Down Expand Up @@ -559,21 +561,21 @@ def _from_data(self, data: AuditLogEntryPayload) -> None:
# into meaningful data when requested
self._changes = data.get("changes", [])

self.user = self._get_member(utils._get_as_snowflake(data, "user_id")) # type: ignore
self._target_id = utils._get_as_snowflake(data, "target_id")
self.user = self._get_member(get_as_snowflake(data, "user_id")) # type: ignore
self._target_id = get_as_snowflake(data, "target_id")

def _get_member(self, user_id: int) -> Member | User | None:
return self.guild.get_member(user_id) or self._users.get(user_id)

def __repr__(self) -> str:
return f"<AuditLogEntry id={self.id} action={self.action} user={self.user!r}>"

@utils.cached_property
@cached_property
def created_at(self) -> datetime.datetime:
"""Returns the entry's creation time in UTC."""
return utils.snowflake_time(self.id)

@utils.cached_property
@cached_property
def target(
self,
) -> (
Expand All @@ -597,24 +599,24 @@ def target(
else:
return converter(self._target_id)

@utils.cached_property
@property
def category(self) -> enums.AuditLogActionCategory:
"""The category of the action, if applicable."""
return self.action.category

@utils.cached_property
@cached_property
def changes(self) -> AuditLogChanges:
"""The list of changes this entry has."""
obj = AuditLogChanges(self, self._changes, state=self._state)
del self._changes
return obj

@utils.cached_property
@property
def before(self) -> AuditLogDiff:
"""The target's prior state."""
return self.changes.before

@utils.cached_property
@property
def after(self) -> AuditLogDiff:
"""The target's subsequent state."""
return self.changes.after
Expand Down
26 changes: 12 additions & 14 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
from .shard import AutoShardedClient
from .types import interactions
from .user import User
from .utils import MISSING, async_all, find, get
from .utils import MISSING, find
from .utils.private import async_all

if TYPE_CHECKING:
from .member import Member
Expand Down Expand Up @@ -216,13 +217,13 @@ def get_application_command(
return command
elif (names := name.split())[0] == command.name and isinstance(command, SlashCommandGroup):
while len(names) > 1:
command = get(commands, name=names.pop(0))
command = find(lambda c: c.name == names.pop(0), commands)
if not isinstance(command, SlashCommandGroup) or (
guild_ids is not None and command.guild_ids != guild_ids
):
return
commands = command.subcommands
command = get(commands, name=names.pop())
command = find(lambda c: c.name == names.pop(), commands)
if not isinstance(command, type) or (guild_ids is not None and command.guild_ids != guild_ids):
return
return command
Expand Down Expand Up @@ -357,7 +358,7 @@ def _check_command(cmd: ApplicationCommand, match: Mapping[str, Any]) -> bool:

# Now let's see if there are any commands on discord that we need to delete
for cmd, value_ in registered_commands_dict.items():
match = get(pending, name=value_["name"])
match = find(lambda c: c.name == value_["name"], pending)
if match is None:
# We have this command registered but not in our list
return_value.append(
Expand Down Expand Up @@ -516,7 +517,7 @@ def register(
)
continue
# We can assume the command item is a command, since it's only a string if action is delete
match = get(pending, name=cmd["command"].name, type=cmd["command"].type)
match = find(lambda c: c.name == cmd["command"].name and c.type == cmd["command"].type, pending)
if match is None:
continue
if cmd["action"] == "edit":
Expand Down Expand Up @@ -605,10 +606,9 @@ def register(
registered = await register("bulk", data, guild_id=guild_id)

for i in registered:
cmd = get(
cmd = find(
lambda c: c.name == i["name"] and c.type == i.get("type"),
self.pending_application_commands,
name=i["name"],
type=i.get("type"),
)
if not cmd:
raise ValueError(f"Registered command {i['name']}, type {i.get('type')} not found in pending commands")
Expand Down Expand Up @@ -712,11 +712,9 @@ async def on_connect():
registered_guild_commands[guild_id] = app_cmds

for i in registered_commands:
cmd = get(
cmd = find(
lambda c: c.name == i["name"] and c.guild_ids is None and c.type == i.get("type"),
self.pending_application_commands,
name=i["name"],
guild_ids=None,
type=i.get("type"),
)
if cmd:
cmd.id = i["id"]
Expand Down Expand Up @@ -803,13 +801,13 @@ async def process_application_commands(self, interaction: Interaction, auto_sync

ctx = await self.get_application_context(interaction)
if command:
ctx.command = command
interaction.command = command
await self.invoke_application_command(ctx)

async def on_application_command_auto_complete(self, interaction: Interaction, command: ApplicationCommand) -> None:
async def callback() -> None:
ctx = await self.get_autocomplete_context(interaction)
ctx.command = command
interaction.command = command
return await command.invoke_autocomplete_callback(ctx)

autocomplete_task = self._bot.loop.create_task(callback())
Expand Down
Loading
Loading