Check User Perms
Aquí tienes la documentación en inglés:
Using checkUserPerms
to Verify User Permissions
checkUserPerms
to Verify User PermissionsImporting Functions:
First, we import
newCommand
andcheckUserPerms
from themvk-project
package. This will allow us to define a new command and check if a user has the necessary permissions to execute it.Defining a New Command:
We define a new command called
test-command
. This command will be executed when invoked in a message.Checking User Permissions:
Inside the command's
code
function, we usecheckUserPerms
to verify if the user who sent the message has the required permissions (ADMINISTRATOR
andMANAGE_GUILD
) in the specific Discord server (guild).Handling Permission Results:
Depending on the result of the permission check, we send a reply to the user. If they have the necessary permissions, they are informed; otherwise, they are notified that they lack the required permissions.
Final Code:
Permission Options:
The checkUserPerms
function allows you to verify the following permissions:
Permission Name | Description |
---|---|
| Grants all permissions and overrides any specific permissions. |
| Allows management and configuration of the guild (server). |
| Allows kicking members from the guild. |
| Allows banning members from the guild. |
| Allows management of channels in the guild. |
| Allows management and deletion of messages. |
| Allows muting members in voice channels. |
| Allows deafening members in voice channels. |
| Allows moving members between voice channels. |
| Allows management of roles in the guild. |
| Allows management of webhooks in the guild. |
| Allows changing and managing nicknames. |
| Allows management of emojis and stickers. |
| Allows management of threads in channels. |
Each permission name corresponds to a specific action or set of actions that a user can perform within the guild, ensuring that only users with the necessary authority can execute certain commands or tasks.
Last updated