Documentation ¶
Overview ¶
Package callbacks provides callback implementations for Discord API events.
Index ¶
- Constants
- type CallbackError
- type ChannelNotFoundError
- func (cnf *ChannelNotFoundError) Error() string
- func (cnf *ChannelNotFoundError) ForMember() *discordgo.Member
- func (*ChannelNotFoundError) InChannel() *discordgo.Channel
- func (cnf *ChannelNotFoundError) InGuild() *discordgo.Guild
- func (cnf *ChannelNotFoundError) Is(target error) bool
- func (cnf *ChannelNotFoundError) Unwrap() error
- type DeadlineExceededError
- func (de *DeadlineExceededError) Error() string
- func (de *DeadlineExceededError) ForMember() *discordgo.Member
- func (de *DeadlineExceededError) InChannel() *discordgo.Channel
- func (de *DeadlineExceededError) InGuild() *discordgo.Guild
- func (de *DeadlineExceededError) Is(target error) bool
- func (de *DeadlineExceededError) Unwrap() error
- type Handler
- func (handler *Handler) ChannelDelete(session *discordgo.Session, channel *discordgo.ChannelDelete)
- func (handler *Handler) Ready(s *discordgo.Session, _ *discordgo.Ready)
- func (handler *Handler) RoleNameFromChannel(channelName string) string
- func (handler *Handler) VoiceStateUpdate(session *discordgo.Session, voiceState *discordgo.VoiceStateUpdate)
- type InsufficientPermissionsError
- func (inp *InsufficientPermissionsError) Error() string
- func (inp *InsufficientPermissionsError) ForMember() *discordgo.Member
- func (inp *InsufficientPermissionsError) InChannel() *discordgo.Channel
- func (inp *InsufficientPermissionsError) InGuild() *discordgo.Guild
- func (inp *InsufficientPermissionsError) Is(target error) bool
- func (inp *InsufficientPermissionsError) Unwrap() error
- type MaxNumberOfRolesError
- func (mnr *MaxNumberOfRolesError) Error() string
- func (mnr *MaxNumberOfRolesError) ForMember() *discordgo.Member
- func (mnr *MaxNumberOfRolesError) InChannel() *discordgo.Channel
- func (mnr *MaxNumberOfRolesError) InGuild() *discordgo.Guild
- func (mnr *MaxNumberOfRolesError) Is(target error) bool
- func (mnr *MaxNumberOfRolesError) Unwrap() error
- type MemberNotFoundError
- func (mnf *MemberNotFoundError) Error() string
- func (*MemberNotFoundError) ForMember() *discordgo.Member
- func (*MemberNotFoundError) InChannel() *discordgo.Channel
- func (mnf *MemberNotFoundError) InGuild() *discordgo.Guild
- func (mnf *MemberNotFoundError) Is(target error) bool
- func (mnf *MemberNotFoundError) Unwrap() error
- type OperationsGateway
- type RoleNotFoundError
Constants ¶
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 ¶
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) RoleNameFromChannel ¶
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 ¶
func (inp *InsufficientPermissionsError) InChannel() *discordgo.Channel
InChannel returns channel metadata for InsufficientPermissionsError.
func (*InsufficientPermissionsError) InGuild ¶
func (inp *InsufficientPermissionsError) InGuild() *discordgo.Guild
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 ¶
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.