You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
I suggest to add permission checking functionality for commands as it's something that will almost always be necessary in most bots and I find myself implementing a lot.
For example, I have recently edited the commands.go file and added a Permission field to the Command struct. With this, I added a middleware that uses a util method I made called HasPermissions which returns a bool I use to either execute the command if the user had the permission assigned on the command or not.
Example struct:
router.RegisterCmd(&dgc.Command{
Name: "Kick",
Description: "Kicks the given member from the guild with the given reason.",
Usage: "kick <@member> <reason>",
Example: "kick @troll Doesn't stop trolling",
IgnoreCase: true,
Permission: discordgo.PermissionKickMembers,
Handler: cmd.Kick,
})
I suggest to add permission checking functionality for commands as it's something that will almost always be necessary in most bots and I find myself implementing a lot.
For example, I have recently edited the
commands.go
file and added a Permission field to the Command struct. With this, I added a middleware that uses a util method I made called HasPermissions which returns a bool I use to either execute the command if the user had the permission assigned on the command or not.Example struct:
Example middleware:
The text was updated successfully, but these errors were encountered: