middlewares

package
v0.0.0-...-f00225b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: OSL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Bot   types.Bot
	Cache map[string]interface{}
}

func (*Bot) BotMiddleware

func (b *Bot) BotMiddleware(next dgc.ExecutionHandler) dgc.ExecutionHandler

type PermissionsMiddleware

type PermissionsMiddleware struct {
	Bot types.Bot
	// contains filtered or unexported fields
}

PermissionsMiddleware is a command handler middleware processing permissions for command execution.

Implements the shireikan.Middleware interface and exposes functions to check permissions.

func (*PermissionsMiddleware) CheckPermissions

func (m *PermissionsMiddleware) CheckPermissions(s *discordgo.Session, guildID, userID, dn string) (bool, bool, error)

CheckPermissions tries to fetch the permissions of the specified user on the specified guild and returns true, if the passed dn matches the fetched permissions array. Also, the override status is returned as well as errors occured during permissions fetching.

func (*PermissionsMiddleware) GetMemberPermission

func (m *PermissionsMiddleware) GetMemberPermission(s *discordgo.Session, guildID string, memberID string) (permissions.PermissionArray, error)

GetMemberPermissions returns a PermissionsArray based on the passed members roles permissions rulesets for the given guild.

func (*PermissionsMiddleware) GetPermissions

func (m *PermissionsMiddleware) GetPermissions(s *discordgo.Session, guildID, userID string) (perm permissions.PermissionArray, overrideExplicits bool, err error)

GetPermissions tries to fetch the permissions array of the passed user of the specified guild. The merged permissions array is returned as well as the override, which is true when the specified user is the bot owner, guild owner or an admin of the guild.

func (*PermissionsMiddleware) Handle

func (*PermissionsMiddleware) UpdateConfig

func (m *PermissionsMiddleware) UpdateConfig(cfg *types.Bot)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL