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

Make @discord.app_commands.default_permissions() take a Permissions object #9951

Closed
2br-2b opened this issue Sep 30, 2024 · 1 comment
Closed
Labels
feature request This is a feature request.

Comments

@2br-2b
Copy link
Contributor

2br-2b commented Sep 30, 2024

Summary

Make @discord.app_commands.default_permissions() take a Permissions object

What is the feature request for?

The core library

The Problem

Right now, I can create a permissions object:

ADMIN_PERMISSIONS = Permissions(
    moderate_members=True
)

and I can add permissions to a function:

new_func = app_commands.default_permissions(moderate_members=True)(new_func)

but I can't pass a Permissions object to the default_permissions() decorator

# Doesn't work
new_func = app_commands.default_permissions(ADMIN_PERMISSIONS)(new_func)

Right now, the decorator just takes the permissions it's passed and creates an object anyway:

permissions = Permissions(**perms)

So I don't see why I can't just pass a Permissions object.

The Ideal Solution

Either modify the default_permissions() decorator to optionally take a Permissions object or create a new decorator that does the same thing.

The Current Solution

  1. Create a function that converts a Permissions object into a list of arguments;
  2. Create a new decorator

Additional Context

Thank you so much for this incredible library!

@2br-2b 2br-2b added the feature request This is a feature request. label Sep 30, 2024
@2br-2b
Copy link
Contributor Author

2br-2b commented Sep 30, 2024

My current solution is to do:

new_func = app_commands.default_permissions(**dict(ADMIN_PERMISSIONS))(new_func)

and it works, but it feels ugly

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

No branches or pull requests

1 participant