From 6a53d7dcd516529aab393b91bc085eb95f1cf980 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Tue, 2 May 2023 16:50:55 +0200 Subject: [PATCH] Add checks submodule to redbot.core.app_commands (#6107) --- redbot/core/app_commands/__init__.py | 3 +++ redbot/core/app_commands/checks.py | 25 +++++++++++++++++++++++++ tests/core/test_app_commands.py | 11 +++++++++++ 3 files changed, 39 insertions(+) create mode 100644 redbot/core/app_commands/checks.py diff --git a/redbot/core/app_commands/__init__.py b/redbot/core/app_commands/__init__.py index b6f613c67..a4b62e316 100644 --- a/redbot/core/app_commands/__init__.py +++ b/redbot/core/app_commands/__init__.py @@ -60,6 +60,8 @@ from discord.app_commands import ( rename as rename, ) +from . import checks as checks + __all__ = ( "AllChannels", "AppCommand", @@ -112,4 +114,5 @@ __all__ = ( "guilds", "locale_str", "rename", + "checks", ) diff --git a/redbot/core/app_commands/checks.py b/redbot/core/app_commands/checks.py new file mode 100644 index 000000000..30ccc466f --- /dev/null +++ b/redbot/core/app_commands/checks.py @@ -0,0 +1,25 @@ +########## SENSITIVE SECTION WARNING ########### +################################################ +# Any edits of any of the exported names # +# may result in a breaking change. # +# Ensure no names are removed without warning. # +################################################ + +### DEP-WARN: Check this *every* discord.py update +from discord.app_commands.checks import ( + bot_has_permissions, + cooldown, + dynamic_cooldown, + has_any_role, + has_role, + has_permissions, +) + +__all__ = ( + "bot_has_permissions", + "cooldown", + "dynamic_cooldown", + "has_any_role", + "has_role", + "has_permissions", +) diff --git a/tests/core/test_app_commands.py b/tests/core/test_app_commands.py index a763ab946..4080632f2 100644 --- a/tests/core/test_app_commands.py +++ b/tests/core/test_app_commands.py @@ -21,3 +21,14 @@ def test_dpy_app_commands_reexports(): "redbot.core.app_commands is missing these names from discord.app_commands: " + ", ".join(missing_attrs) ) + + +def test_dpy_app_commands_checks_reexports(): + dpy_attrs = set(dpy_app_commands.checks.__all__) + missing_attrs = dpy_attrs - set(app_commands.checks.__dict__.keys()) + + if missing_attrs: + pytest.fail( + "redbot.core.app_commands.checks is missing these names from discord.app_commands: " + + ", ".join(missing_attrs) + )