From 614f79409ca3fb1e335e4ed8f900f2dbbe8b3b2c Mon Sep 17 00:00:00 2001 From: Om <92863779+Om1609@users.noreply.github.com> Date: Fri, 31 Mar 2023 20:05:21 +0530 Subject: [PATCH 1/4] fix: attribute error with listeners in cogs (#1989) * fix attribute error Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit 3375d386bc662d9ddca6c60ecf620dbc00c0a3b3. * Revert "fix attribute error" This reverts commit b8733f2a549c51551a556ccd16f7af75573bc936. * fix using EAPF * Changelog and comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update CHANGELOG.md Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> --------- Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com> --- CHANGELOG.md | 6 ++++++ discord/client.py | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb78469987..dd044d7072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,12 @@ These changes are available on the `master` branch, but have not yet been releas - Removed `@client.once()` in favour of `@client.listen(once=True)`. ([#1957](https://github.com/Pycord-Development/pycord/pull/1957)) +### Fixed + +- Fixed `AttributeError` caused by + [#1957](https://github.com/Pycord-Development/pycord/pull/1957) when using listeners + in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989)) + ## [2.4.1] - 2023-03-20 ### Changed diff --git a/discord/client.py b/discord/client.py index a6849a205b..654219a0bd 100644 --- a/discord/client.py +++ b/discord/client.py @@ -442,8 +442,18 @@ def dispatch(self, event: str, *args: Any, **kwargs: Any) -> None: # Schedule additional handlers registered with @listen for coro in self._event_handlers.get(method, []): self._schedule_event(coro, method, *args, **kwargs) - if coro._once: - once_listeners.append(coro) + + try: + if coro._once: # added using @listen() + once_listeners.append(coro) + + except AttributeError: # added using @Cog.add_listener() + # https://github.com/Pycord-Development/pycord/pull/1989 + # Although methods are similar to functions, attributes can't be added to them. + # This means that we can't add the `_once` attribute in the `add_listener` method + # and can only be added using the `@listen` decorator. + + continue # remove the once listeners for coro in once_listeners: From 4a5099a59ce561d4eca5c889662b24a4e887fe08 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Mon, 3 Apr 2023 02:01:57 -0400 Subject: [PATCH 2/4] fix(scheduled_events): location editing breaking (#1998) * fix(scheduled_events): location breaking * chore(changelog): changelog --- CHANGELOG.md | 2 ++ discord/scheduled_events.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd044d7072..57d0af8f6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed `AttributeError` caused by [#1957](https://github.com/Pycord-Development/pycord/pull/1957) when using listeners in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989)) +- Fixed scheduled events breaking when changing the location from external to a channel. + ([#1998](https://github.com/Pycord-Development/pycord/pull/1998)) ## [2.4.1] - 2023-03-20 diff --git a/discord/scheduled_events.py b/discord/scheduled_events.py index 8fefdc2c24..6f70ff88c6 100644 --- a/discord/scheduled_events.py +++ b/discord/scheduled_events.py @@ -359,6 +359,8 @@ async def edit( payload["channel_id"] = location.value.id payload["entity_metadata"] = None + payload["entity_type"] = location.type.value + location = location if location is not MISSING else self.location if end_time is MISSING and location.type is ScheduledEventLocationType.external: end_time = self.end_time From 279f616b392c78d3b2cdecf50830a5dd06e92b0d Mon Sep 17 00:00:00 2001 From: Om <92863779+Om1609@users.noreply.github.com> Date: Mon, 3 Apr 2023 21:52:13 +0530 Subject: [PATCH 3/4] fix: bridge command group name (#2000) * fix double name parameter * Update CHANGELOG.md Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> --------- Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/ext/bridge/core.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d0af8f6d..951baa9f2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ These changes are available on the `master` branch, but have not yet been releas in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989)) - Fixed scheduled events breaking when changing the location from external to a channel. ([#1998](https://github.com/Pycord-Development/pycord/pull/1998)) +- Fixed `TypeError` being raised when passing `name` argument to bridge groups. + ([#2000](https://github.com/Pycord-Development/pycord/pull/2000)) ## [2.4.1] - 2023-03-20 diff --git a/discord/ext/bridge/core.py b/discord/ext/bridge/core.py index 0985526ab0..8c9a69d265 100644 --- a/discord/ext/bridge/core.py +++ b/discord/ext/bridge/core.py @@ -325,10 +325,12 @@ class BridgeCommandGroup(BridgeCommand): slash_variant: BridgeSlashGroup def __init__(self, callback, *args, **kwargs): + ext_var = BridgeExtGroup(callback, *args, **kwargs) + kwargs.update({"name": ext_var.name}) super().__init__( callback, - ext_variant=(ext_var := BridgeExtGroup(callback, *args, **kwargs)), - slash_variant=BridgeSlashGroup(callback, ext_var.name, *args, **kwargs), + ext_variant=ext_var, + slash_variant=BridgeSlashGroup(callback, *args, **kwargs), parent=kwargs.pop("parent", None), ) From 982c5d8c5230e3f9f68a614600834b7306172159 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 23:11:40 +0200 Subject: [PATCH 4/4] chore(deps-dev): Update pylint requirement from ~=2.17.1 to ~=2.17.2 (#2002) Updates the requirements on [pylint](https://github.com/PyCQA/pylint) to permit the latest version. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Commits](https://github.com/PyCQA/pylint/compare/v2.17.1...v2.17.2) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 00ff7b8c74..3bef44d1b0 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,5 +1,5 @@ -r _.txt -pylint~=2.17.1 +pylint~=2.17.2 pytest~=7.2.2 pytest-asyncio~=0.21.0 # pytest-order~=1.0.1