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

You don't have permissions to use this command. (discord.py 2.4.0 final) #9884

Open
3 tasks done
tjf1dev opened this issue Jul 11, 2024 · 2 comments
Open
3 tasks done
Labels
invalid This is not right.

Comments

@tjf1dev
Copy link

tjf1dev commented Jul 11, 2024

Summary

My command gives me a permission error even if its not in the code.

Reproduction Steps

@commands.is_owner()
@app_commands.user_install()
@app_commands.allowed_contexts(guilds=True,dms=True,private_channels=True)
@tree.command(
    name="admin",
    description="This is an admin command. No info will be given."
)
async def admin(interaction,id:int,arg1:str=None,arg2:str=None,bool:bool=None):
    if id==1:
        if not arg1.startswith("<@"):        
            user = await client.fetch_user(arg1)
            profile = db.reference(f"/profiles/users/{arg1}")
            profile.set({})
            if bool!=False:
                await user.send("Hello! Your profile has been removed due to recent changes. You can always create it again with /menu")
            response = "ID: 1 - Remove user profile. Successful"
            await interaction.response.send_message(f"{response}",ephemeral=True)
        else:
            await interaction.response.send_message(f"arg1 must be an ID.",ephemeral=True)
    
    elif id==2:
        try:
            if arg1 == 'guild':
                await tree.sync(guild=discord.Object(id=<guild id>))
                response = "ID: 2 - Sync guild command tree. Successful"
            else:
                response = "ID: 2 - Sync global command tree. Successful"
                await tree.sync()
        except discord.HTTPException:
            response = "ID: 2 - Sync global command tree. Failed"
        await interaction.response.send_message(f"{response}",ephemeral=True)
    else:
        response="Unknown ID."
        await interaction.response.send_message(f"{response}",ephemeral=True)

Ran command /admin id:1 arg1:<someone's id> bool:True

Minimal Reproducible Code

No response

Expected Results

I expected that the command will output "ID: 1 - Remove user profile. Successful"

Actual Results

Console: No output

It sent a message saying "You don't have permissions to use this command."

Intents

all

System Information

  • Python v3.12.4-final
  • discord.py v2.4.0-final
  • aiohttp v3.9.5
  • system info: Windows 11 10.0.22631

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

No response

@tjf1dev tjf1dev added the unconfirmed bug A bug report that needs triaging label Jul 11, 2024
@tjf1dev tjf1dev changed the title commands.is_owner You don't have permissions to use this command. commands.is_owner You don't have permissions to use this command. (discord.py 2.4.0 final) Jul 11, 2024
@tjf1dev
Copy link
Author

tjf1dev commented Jul 11, 2024

oh actually im running Linux 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 (on my vps)

@tjf1dev tjf1dev changed the title commands.is_owner You don't have permissions to use this command. (discord.py 2.4.0 final) You don't have permissions to use this command. (discord.py 2.4.0 final) Jul 11, 2024
@Rapptz Rapptz added invalid This is not right. and removed unconfirmed bug A bug report that needs triaging labels Jul 11, 2024
@Rapptz
Copy link
Owner

Rapptz commented Jul 11, 2024

commands.is_owner() is not meant to be used with interactions. The library also doesn't have a string that says this, so this is some combination on your end that's triggering it. If you want to receive help for this you're going to need to provide more information, like a traceback or something. Either way, currently the code as given is not necessarily valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This is not right.
Projects
None yet
Development

No branches or pull requests

2 participants