handler

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Overview

Copyright (C) 2022-2023  sabafly

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutocompleteHandler

type AutocompleteHandler func(event *events.AutocompleteInteractionCreate) error

type Check

type Check[T any] func(ctx T) bool

func CheckAllOf

func CheckAllOf[T any](checks ...Check[T]) Check[T]

func CheckAnyOf

func CheckAnyOf[T any](checks ...Check[T]) Check[T]

func (Check[T]) And

func (c Check[T]) And(check Check[T]) Check[T]

func (Check[T]) Or

func (c Check[T]) Or(check Check[T]) Check[T]

type CommandHandler

type CommandHandler func(event *events.ApplicationCommandInteractionCreate) error

type Component

type Component struct {
	Name    string
	Check   Check[*events.ComponentInteractionCreate]
	Checks  map[string]Check[*events.ComponentInteractionCreate]
	Handler map[string]ComponentHandler
}

type ComponentHandler

type ComponentHandler func(event *events.ComponentInteractionCreate) error

type Event added in v2.4.0

type Event struct {
	ID *uuid.UUID

	Check   Check[bot.Event]
	Handler RawHandler
}

type Generics added in v2.4.1

type Generics[T any] struct {
	ID *uuid.UUID

	Check   Check[*T]
	Handler GenericsHandler[T]
}

type GenericsHandler added in v2.4.1

type GenericsHandler[T any] func(event *T) error

type Handler

type Handler struct {
	Logger log.Logger

	Commands                   map[string]Command
	Components                 map[string]Component
	Modals                     map[string]Modal
	Message                    map[uuid.UUID]Message
	MessageUpdate              map[uuid.UUID]MessageUpdate
	MessageDelete              map[uuid.UUID]MessageDelete
	Ready                      []func(*events.Ready)
	MemberJoin                 genericsList[events.GuildMemberJoin]
	MemberLeave                genericsList[events.GuildMemberLeave]
	MemberUpdate               genericsList[events.GuildMemberUpdate]
	MessageReactionAdd         genericsList[events.GuildMessageReactionAdd]
	MessageReactionRemove      genericsList[events.GuildMessageReactionRemove]
	MessageReactionRemoveAll   genericsList[events.GuildMessageReactionRemoveAll]
	MessageReactionRemoveEmoji genericsList[events.GuildMessageReactionRemoveEmoji]
	Event                      []Event

	Static StaticHandler

	ExcludeID  map[snowflake.ID]struct{}
	DevGuildID []snowflake.ID
	IsDebug    bool
	ASync      bool
	IsLogEvent bool
}

func New

func New(logger log.Logger) *Handler

func (*Handler) AddCommands

func (h *Handler) AddCommands(commands ...Command)

func (*Handler) AddComponent

func (h *Handler) AddComponent(component Component) func()

func (*Handler) AddComponents

func (h *Handler) AddComponents(components ...Component)

func (*Handler) AddEvent added in v2.4.0

func (h *Handler) AddEvent(events ...Event)

func (*Handler) AddExclude

func (h *Handler) AddExclude(ids ...snowflake.ID)

func (*Handler) AddMessage

func (h *Handler) AddMessage(message Message) func()

func (*Handler) AddMessageDelete added in v2.4.0

func (h *Handler) AddMessageDelete(messageDelete MessageDelete) func()

func (*Handler) AddMessageDeletes added in v2.4.0

func (h *Handler) AddMessageDeletes(messageDeletes ...MessageDelete)

func (*Handler) AddMessageUpdate added in v2.4.0

func (h *Handler) AddMessageUpdate(messageUpdate MessageUpdate) func()

func (*Handler) AddMessageUpdates added in v2.4.0

func (h *Handler) AddMessageUpdates(messageUpdates ...MessageUpdate)

func (*Handler) AddMessages added in v2.1.0

func (h *Handler) AddMessages(messages ...Message)

func (*Handler) AddModals

func (h *Handler) AddModals(modals ...Modal)

func (*Handler) AddReady

func (h *Handler) AddReady(ready func(*events.Ready))

func (*Handler) OnEvent

func (h *Handler) OnEvent(event bot.Event)

func (*Handler) SyncCommands

func (h *Handler) SyncCommands(client bot.Client, guildIDs ...snowflake.ID)

type Message

type Message struct {
	UUID      *uuid.UUID
	ChannelID *snowflake.ID
	AuthorID  *snowflake.ID
	Check     Check[*events.GuildMessageCreate]
	Handler   MessageHandler
}

type MessageDelete added in v2.4.0

type MessageDelete struct {
	UUID      *uuid.UUID
	ChannelID *snowflake.ID
	AuthorID  *snowflake.ID
	Check     Check[*events.GuildMessageDelete]
	Handler   MessageDeleteHandler
}

type MessageDeleteHandler added in v2.4.0

type MessageDeleteHandler func(event *events.GuildMessageDelete) error

type MessageHandler

type MessageHandler func(event *events.GuildMessageCreate) error

type MessageUpdate added in v2.4.0

type MessageUpdate struct {
	UUID      *uuid.UUID
	ChannelID *snowflake.ID
	AuthorID  *snowflake.ID
	Check     Check[*events.GuildMessageUpdate]
	Handler   MessageUpdateHandler
}

type MessageUpdateHandler added in v2.4.0

type MessageUpdateHandler func(event *events.GuildMessageUpdate) error

type ModalHandler

type ModalHandler func(event *events.ModalSubmitInteractionCreate) error

type RawHandler added in v2.4.0

type RawHandler func(event bot.Event) error

type StaticHandler added in v2.4.0

type StaticHandler struct {
	Message       []Message
	MessageUpdate []MessageUpdate
	MessageDelete []MessageDelete
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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