Closed 2br-2b closed 3 weeks ago
Make @discord.app_commands.default_permissions() take a Permissions object
The core library
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:
https://github.com/Rapptz/discord.py/blob/59f877fcf013c4ddeeb2b39fc21f03e76f995461/discord/app_commands/commands.py#L2860
So I don't see why I can't just pass a Permissions object.
Either modify the default_permissions() decorator to optionally take a Permissions object or create a new decorator that does the same thing.
Thank you so much for this incredible library!
My current solution is to do:
new_func = app_commands.default_permissions(**dict(ADMIN_PERMISSIONS))(new_func)
and it works, but it feels ugly
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:
and I can add permissions to a function:
but I can't pass a Permissions object to the default_permissions() decorator
Right now, the decorator just takes the permissions it's passed and creates an object anyway:
https://github.com/Rapptz/discord.py/blob/59f877fcf013c4ddeeb2b39fc21f03e76f995461/discord/app_commands/commands.py#L2860
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
Additional Context
Thank you so much for this incredible library!