'How can I create a Permission object using the .value int gotten from another Permissions object?
I've looked through the docs but I can't seem to find it. How can I create a Permissions object with the .value int gotten from another Permissions object? I'm trying to duplicate permissions from one role to another. I know of another way to do this but I feel like this is the most efficient method, if it's possible.
I am using the discord.py library
I am trying to upload the permissions to a database, otherwise I would do this. For context, I am creating a command to undo the deletion of a role. If a user deletes a role using the delete role command on the bot, it will upload all information pertaining to the role (members, permissions, name, etc..), and the user can use a command to undo the deletion if they regret it later. As far as I know, it's not possible to upload objects to databases.
Solution 1:[1]
To copy the perms of a role you can do this:
from discord.utils import get
role_id = "roleID"
role = get(guild.roles, id=role_id)
roleperms = role.permissions
# Then create the role
author = ctx.message.author
await bot.create_role(author.server, name="rolename", permissions=perms)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mr bean |
