msghandler

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResponse = errors.New("no response")

ErrNoResponse is the error a command handler should return if the bot should not produce a response

View Source
var ErrUnauthorized = errors.New("unauthorized")

ErrUnauthorized is the error a command handler should return if the user does not have permission to perform the requested action

Functions

func HasAdminRole added in v0.11.0

func HasAdminRole(ctx context.Context, logger Logger, sess *session.Session, msg MessageLike, adminRoles []string, b *bot.DiscordBot) bool

HasAdminRole determines if the message author is an authorized bot admin (not super-admin)

func IsAdminAuthorized added in v0.11.0

func IsAdminAuthorized(ctx context.Context, logger Logger, msg MessageLike, adminRoles []string, sess *session.Session, b *bot.DiscordBot) bool

IsAdminAuthorized determines if a user can take admin actions with the bot (ignoring channel)

func IsAdminChannel added in v0.11.0

func IsAdminChannel(logger Logger, msg MessageLike, adminChannel string, sess *session.Session) bool

IsAdminChannel determines if a message is occurring in the admin channel for a guild

func IsSignupChannel added in v0.11.0

func IsSignupChannel(msg MessageLike, signupChannel string, sess *session.Session) bool

IsSignupChannel determines if a message is occurring in the designated signup channel for a guild

Types

type Handlers

type Handlers interface {
	ConnectToBot(*bot.DiscordBot)
}

Handlers is the interface for a Handlers dependency that registers itself with a discrord bot

func NewHandlers

func NewHandlers(deps dependencies, opts Options) Handlers

NewHandlers creates a new Handlers object

type Logger added in v0.26.0

type Logger = interface {
	Log(keyvals ...interface{}) error
	Message(string, ...interface{})
	Err(string, error, ...interface{})
	Printf(string, ...interface{})
}

type MessageLike added in v0.23.0

type MessageLike interface {
	UserID() snowflake.Snowflake
	GuildID() snowflake.Snowflake
	ChannelID() snowflake.Snowflake
}

type Options

type Options struct {
	DefaultCommandIndicator string
	SuccessColor            int
	ErrorColor              int
}

Options provides a way to pass configuration to NewHandlers

Jump to

Keyboard shortcuts

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