Skip to content
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

application_checks error #1163

Open
3 tasks done
eeemoon opened this issue Feb 6, 2024 · 3 comments
Open
3 tasks done

application_checks error #1163

eeemoon opened this issue Feb 6, 2024 · 3 comments
Labels
t: unconfirmed bug Type: bug - needs testing on if this is an issue

Comments

@eeemoon
Copy link

eeemoon commented Feb 6, 2024

Summary

application_checks.check_any() raises a TypeError

Reproduction Steps

Wrap a slash command in application_checks.check_any() decorator with has_permissions() or has_guild_permissions() checks.

Minimal Reproducible Code

import nextcord
from nextcord.ext import commands, application_checks


bot = commands.Bot(intents=nextcord.Intents.all())


class TestCog(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot: commands.Bot = bot

    @nextcord.slash_command()
    @application_checks.check_any(
        application_checks.has_permissions(administrator=True)
    )
    async def test(self, interaction: nextcord.Interaction):
        await interaction.send('Hello World')
    

bot.add_cog(TestCog(bot))

bot.run('TOKEN')

Expected Results

The slash command registers without any errors.

Actual Results

Traceback (most recent call last):
  File "d:\gradientbot\tests\test.py", line 17, in <module>
    class TestCog(commands.Cog):
  File "d:\gradientbot\tests\test.py", line 22, in TestCog
    @application_checks.check_any(
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\gradientbot\venv\Lib\site-packages\nextcord\ext\application_checks\core.py", line 223, in check_any
    raise TypeError(
TypeError: <function _permission_check_wrapper.<locals>.wrapper at 0x000001DE62F423E0> must be wrapped by application_checks.check decorator   

Intents

nextcord.Intents.all()

System Information

  • Python v3.11.5-final
  • nextcord v2.6.0-final
  • aiohttp v3.9.1
  • system info: Windows 10 10.0.19045

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

The problem seems to occur only with these checks:

  • has_permissions
  • has_guild_permissions
  • bot_has_permissions
  • bot_has_guild_permissions

This decorator works fine:

@application_checks.check_any(
    application_checks.is_owner(),
)
@eeemoon eeemoon added the t: unconfirmed bug Type: bug - needs testing on if this is an issue label Feb 6, 2024
@eeemoon eeemoon changed the title Application checks error application_checks error Feb 6, 2024
@A1Asriel
Copy link

A1Asriel commented Mar 12, 2024

Same happens with nextcord.ext.commands.check_any() and nextcord.ext.commands.has_guild_permissions(). Most likely, the issue affects every permission check.

  • Code:
import nextcord
from nextcord.ext import commands

client = commands.Bot("test!", intents=nextcord.Intents.all())

@client.command()
@commands.check_any(commands.has_guild_permissions(manage_guild=True))
async def ping(ctx: commands.Context):
    return await ctx.send("Pong!")

client.run("TOKEN")
  • Traceback:
Traceback (most recent call last):
  File "c:\path\to\bot\main.py", line 8, in <module>
    @commands.check_any(commands.has_guild_permissions(manage_guild=True))
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\path\to\bot\.venv\Lib\site-packages\nextcord\ext\commands\core.py", line 1929, in check_any
    raise TypeError(f"{wrapped!r} must be wrapped by commands.check decorator") from None
TypeError: <function _permission_check_wrapper.<locals>.wrapper at 0x0000026C5B01D800> must be wrapped by commands.check decorator
  • System info: Python 3.11.8, Nextcord-3.0.0a25+g1c860268, aiohttp 3.9.3, Windows 11 22631.3155.

@ooliver1
Copy link
Member

This is not the same @A1Asriel, that is ext.commands.

@A1Asriel
Copy link

A1Asriel commented Mar 12, 2024

This is not the same @A1Asriel, that is ext.commands.

I understand, but even if it's in another module, it still produces the same error and is triggered by the same conditions. I can open another issue, if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: unconfirmed bug Type: bug - needs testing on if this is an issue
Projects
None yet
Development

No branches or pull requests

3 participants