callbacks

package
v0.0.0-...-6d2f78d Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package callbacks provides callback implementations for Discord API events.

Index

Constants

View Source
const (
	MemberNotFoundMessage         = "member not found"
	ChannelNotFoundMessage        = "channel not found"
	RoleNotFoundMessage           = "role not found"
	InsufficientPermissionMessage = "insufficient permissions"
	MaxNumberOfRolesMessage       = "max number of roles"
	DeadlineExceededMessage       = "deadline exceeded"
)

Error messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackError

type CallbackError interface {
	error
	Is(err error) bool
	Unwrap() error
	InGuild() *discordgo.Guild
	ForMember() *discordgo.Member
	InChannel() *discordgo.Channel
}

CallbackError embeds the error interface with additional methods to provide metadata for the error.

type ChannelNotFoundError

type ChannelNotFoundError struct {
	Guild  *discordgo.Guild
	Member *discordgo.Member
	Err    error
}

ChannelNotFoundError represents an error when a channel is not found.

func (*ChannelNotFoundError) Error

func (cnf *ChannelNotFoundError) Error() string

Error satisfies the errors interface for ChannelNotFoundError.

func (*ChannelNotFoundError) ForMember

func (cnf *ChannelNotFoundError) ForMember() *discordgo.Member

ForMember returns member metadata for ChannelNotFoundError.

func (*ChannelNotFoundError) InChannel

func (*ChannelNotFoundError) InChannel() *discordgo.Channel

InChannel satisfies the CallbackError interface for ChannelNotFoundError.

func (*ChannelNotFoundError) InGuild

func (cnf *ChannelNotFoundError) InGuild() *discordgo.Guild

InGuild returns guild metadata for ChannelNotFoundError.

func (*ChannelNotFoundError) Is

func (cnf *ChannelNotFoundError) Is(target error) bool

Is allows ChannelNotFoundError to be compared with errors.Is.

func (*ChannelNotFoundError) Unwrap

func (cnf *ChannelNotFoundError) Unwrap() error

Unwrap returns an error wrapped by ChannelNotFoundError.

type DeadlineExceededError

type DeadlineExceededError struct {
	Guild   *discordgo.Guild
	Member  *discordgo.Member
	Channel *discordgo.Channel
	Err     error
}

DeadlineExceededError represents an error for when a context deadline has been exceeded.

func (*DeadlineExceededError) Error

func (de *DeadlineExceededError) Error() string

Error satisfies the errors interface for DeadlineExceededError.

func (*DeadlineExceededError) ForMember

func (de *DeadlineExceededError) ForMember() *discordgo.Member

ForMember returns member metadata for DeadlineExceededError.

func (*DeadlineExceededError) InChannel

func (de *DeadlineExceededError) InChannel() *discordgo.Channel

InChannel returns channel metadata for DeadlineExceededError.

func (*DeadlineExceededError) InGuild

func (de *DeadlineExceededError) InGuild() *discordgo.Guild

InGuild returns guild metadata for DeadlineExceededError.

func (*DeadlineExceededError) Is

func (de *DeadlineExceededError) Is(target error) bool

Is allows DeadlineExceededError to be compared with errors.Is.

func (*DeadlineExceededError) Unwrap

func (de *DeadlineExceededError) Unwrap() error

Unwrap returns an error wrapped by DeadlineExceededError.

type Handler

type Handler struct {
	Log                     logging.Interface
	BotName                 string
	RolePrefix              string
	RoleColor               int
	JaegerTracer            opentracing.Tracer
	ContextTimeout          time.Duration
	ReadyCounter            prometheus.Counter
	VoiceStateUpdateCounter prometheus.Counter
	OperationsGateway       OperationsGateway
}

Handler contains fields for the callback methods attached to it.

func (*Handler) ChannelDelete

func (handler *Handler) ChannelDelete(session *discordgo.Session, channel *discordgo.ChannelDelete)

ChannelDelete is the callback function for the ChannelDelete event from Discord.

func (*Handler) Ready

func (handler *Handler) Ready(s *discordgo.Session, _ *discordgo.Ready)

Ready is the callback function for the Ready event from Discord.

func (*Handler) RoleNameFromChannel

func (handler *Handler) RoleNameFromChannel(channelName string) string

RoleNameFromChannel returns the name of a role for a channel, with the bot keyword prefixed.

func (*Handler) VoiceStateUpdate

func (handler *Handler) VoiceStateUpdate(session *discordgo.Session, voiceState *discordgo.VoiceStateUpdate)

VoiceStateUpdate is the callback function for the VoiceStateUpdate event from Discord.

type InsufficientPermissionsError

type InsufficientPermissionsError struct {
	Guild   *discordgo.Guild
	Member  *discordgo.Member
	Channel *discordgo.Channel
	Err     error
}

InsufficientPermissionsError represents an error for when the bot lacks role privileges to perform an operation.

func (*InsufficientPermissionsError) Error

func (inp *InsufficientPermissionsError) Error() string

Error satisfies the errors interface for InsufficientPermissionsError.

func (*InsufficientPermissionsError) ForMember

func (inp *InsufficientPermissionsError) ForMember() *discordgo.Member

ForMember returns member metadata for InsufficientPermissionsError.

func (*InsufficientPermissionsError) InChannel

InChannel returns channel metadata for InsufficientPermissionsError.

func (*InsufficientPermissionsError) InGuild

InGuild returns guild metadata for InsufficientPermissionsError.

func (*InsufficientPermissionsError) Is

func (inp *InsufficientPermissionsError) Is(target error) bool

Is allows InsufficientPermissionsError to be compared with errors.Is.

func (*InsufficientPermissionsError) Unwrap

func (inp *InsufficientPermissionsError) Unwrap() error

Unwrap returns an error wrapped by InsufficientPermissionsError.

type MaxNumberOfRolesError

type MaxNumberOfRolesError struct {
	Guild   *discordgo.Guild
	Member  *discordgo.Member
	Channel *discordgo.Channel
	Err     error
}

MaxNumberOfRolesError represents an error for when a guild already has the max number of roles allowed.

func (*MaxNumberOfRolesError) Error

func (mnr *MaxNumberOfRolesError) Error() string

Error satisfies the errors interface for MaxNumberOfRolesError.

func (*MaxNumberOfRolesError) ForMember

func (mnr *MaxNumberOfRolesError) ForMember() *discordgo.Member

ForMember returns member metadata for MaxNumberOfRolesError.

func (*MaxNumberOfRolesError) InChannel

func (mnr *MaxNumberOfRolesError) InChannel() *discordgo.Channel

InChannel returns channel metadata for MaxNumberOfRolesError.

func (*MaxNumberOfRolesError) InGuild

func (mnr *MaxNumberOfRolesError) InGuild() *discordgo.Guild

InGuild returns guild metadata for MaxNumberOfRolesError.

func (*MaxNumberOfRolesError) Is

func (mnr *MaxNumberOfRolesError) Is(target error) bool

Is allows MaxNumberOfRolesError to be compared with errors.Is.

func (*MaxNumberOfRolesError) Unwrap

func (mnr *MaxNumberOfRolesError) Unwrap() error

Unwrap returns an error wrapped by MaxNumberOfRolesError.

type MemberNotFoundError

type MemberNotFoundError struct {
	Guild *discordgo.Guild
	Err   error
}

MemberNotFoundError represents an error when a member is not found.

func (*MemberNotFoundError) Error

func (mnf *MemberNotFoundError) Error() string

Error satisfies the errors interface for MemberNotFoundError.

func (*MemberNotFoundError) ForMember

func (*MemberNotFoundError) ForMember() *discordgo.Member

ForMember satisfies the CallbackError interface for MemberNotFoundError.

func (*MemberNotFoundError) InChannel

func (*MemberNotFoundError) InChannel() *discordgo.Channel

InChannel satisfies the CallbackError interface for MemberNotFoundError.

func (*MemberNotFoundError) InGuild

func (mnf *MemberNotFoundError) InGuild() *discordgo.Guild

InGuild returns guild metadata for MemberNotFoundError.

func (*MemberNotFoundError) Is

func (mnf *MemberNotFoundError) Is(target error) bool

Is allows MemberNotFoundError to be compared with errors.Is.

func (*MemberNotFoundError) Unwrap

func (mnf *MemberNotFoundError) Unwrap() error

Unwrap returns an error wrapped by MemberNotFoundError.

type OperationsGateway

type OperationsGateway interface {
	Process(request *operations.Request) <-chan singleflight.Result
}

OperationsGateway is an interface abstraction for processing operations requests.

type RoleNotFoundError

type RoleNotFoundError struct{}

RoleNotFoundError represents an error for when the bot fails to find a role.

func (*RoleNotFoundError) Error

func (*RoleNotFoundError) Error() string

Error satisfies the errors interface for RoleNotFoundError.

Jump to

Keyboard shortcuts

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