From 02c6b078340541023bc23c15a76f29bfd2363666 Mon Sep 17 00:00:00 2001 From: Gnome! <45660393+Gnome-py@users.noreply.github.com> Date: Tue, 21 Sep 2021 22:34:54 +0100 Subject: [PATCH 1/3] Merge pull request #72 * Fix command checks actually working --- discord/ext/commands/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 5947dc19..5d48eb8f 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -399,9 +399,9 @@ class Command(_BaseCommand, Generic[CogT, P, T]): command_attrs = {} try: - checks = command_attrs.pop("checks") + checks = func.__commands_checks__ checks.reverse() - except KeyError: + except AttributeError: checks = kwargs.get("checks", []) try: -- 2.47.2 From 0637a628caa8734a6a12156ab7a340ddd0e63576 Mon Sep 17 00:00:00 2001 From: Tom <47765953+IAmTomahawkx@users.noreply.github.com> Date: Tue, 21 Sep 2021 14:51:46 -0700 Subject: [PATCH 2/3] update workflows (#73) * modify workflows to fit into one file, fix pyright workflow * remove redundant pip install * add check flag to black * use psf/black for black checker --- .github/workflows/black.yml | 25 ------------------------- .github/workflows/ci.yml | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index b95fb1dd..00000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Lint - -on: [push] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: install black - run: pip install black - - - name: run linter - uses: wearerequired/lint-action@v1 - with: - black: true - black_args: ". --line-length 120" - auto_fix: true \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4dd5c56..27a7e1d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: CI on: [push, pull_request] jobs: - lint: + pyright: runs-on: ubuntu-latest steps: - name: checkout @@ -22,5 +22,17 @@ jobs: - name: Run type checking run: | npm install -g pyright - pip install -r requirements.txt + pip install . pyright --lib --verifytypes discord --ignoreexternal + + black: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run linter + uses: psf/black@stable + with: + options: "--line-length 120 --check" + src: "./discord" \ No newline at end of file -- 2.47.2 From f47ac718c3d415ec928e3202c808a519c31ce6e3 Mon Sep 17 00:00:00 2001 From: Gnome <david2005thomas@gmail.com> Date: Thu, 23 Sep 2021 17:32:44 +0100 Subject: [PATCH 3/3] Fix slash command prefix to / --- discord/ext/commands/bot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index 7abd6c8a..b438b4fe 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -1065,6 +1065,9 @@ class BotBase(GroupMixin): A list of prefixes or a single prefix that the bot is listening for. """ + if isinstance(message, _FakeSlashMessage): + return "/" + prefix = ret = self.command_prefix if callable(prefix): ret = await discord.utils.maybe_coroutine(prefix, self, message) @@ -1261,15 +1264,12 @@ class BotBase(GroupMixin): else: return # cannot do anything without stable channel - # Fetch a valid prefix, so process_commands can function + # Make our fake message so we can pass it to ext.commands message: discord.Message = _FakeSlashMessage.from_interaction(interaction, channel) # type: ignore - prefix = await self.get_prefix(message) - if isinstance(prefix, list): - prefix = prefix[0] + message.content = f"/{command_name} " # Add arguments to fake message content, in the right order ignore_params: List[inspect.Parameter] = [] - message.content = f"{prefix}{command_name} " for name, param in command.clean_params.items(): if inspect.isclass(param.annotation) and issubclass(param.annotation, FlagConverter): for name, flag in param.annotation.get_flags().items(): -- 2.47.2