Documentation
¶
Index ¶
- type Config
- type GuildConfiguration
- type GuildManager
- func (mng *GuildManager) AddHandler(handler interface{})
- func (mng *GuildManager) BotUser() *discordgo.User
- func (mng *GuildManager) CommandHandler() *command.CommandHandler
- func (mng *GuildManager) Connection() *gorm.DB
- func (mng *GuildManager) GlobalManager() *Manager
- func (mng *GuildManager) Guild() *discordgo.Guild
- func (mng *GuildManager) ListenForComponent(customId string, handler component.ComponentHandlerFunc)
- func (mng *GuildManager) Logger() log.Logger
- func (mng *GuildManager) ModalHandler() *modal.ModalHandler
- func (mng *GuildManager) Save() error
- func (mng *GuildManager) Session() *discordgo.Session
- func (mng *GuildManager) Start() error
- func (mng *GuildManager) Stop() error
- type Manager
- func (mng *Manager) BotUser() *discordgo.User
- func (mng *Manager) Config() *Config
- func (mng *Manager) Connection() *gorm.DB
- func (mng *Manager) CreateServices(guildManager *GuildManager) []Service
- func (mng *Manager) GuildExists(guildID string) bool
- func (mng *Manager) GuildManager(guildID string) (*GuildManager, error)
- func (mng *Manager) Logger() log.Logger
- func (mng *Manager) Member(guildID string) (*discordgo.Member, error)
- func (mng *Manager) OnStart(f ManagerStartFunc)
- func (mng *Manager) RegisterService(s Service)
- func (mng *Manager) Session() *discordgo.Session
- func (mng *Manager) Start() error
- func (mng *Manager) Stop()
- type ManagerStartFunc
- type Service
- type StringArray
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// The token used to authenticate with Discord
Token string
// The string used to connect to the database
DatabaseString string
}
Config is the structure that holds the configuration for the manager It holds the token used to authenticate with Discord and the string used to connect to the database
type GuildConfiguration ¶
type GuildConfiguration struct {
// GuildID is the ID of the guild and is used as the primary key
GuildID string `gorm:"primarykey"`
}
GuildConfiguration is the structure that holds the configuration for a single guild
type GuildManager ¶
type GuildManager struct {
// contains filtered or unexported fields
}
GuildManager is the structure that manages all of the services for a single guild It holds the guild's ID, its configuration, the database connection, and the Discord session
func CreateGuildManager ¶
func CreateGuildManager(manager *Manager, config *GuildConfiguration) (*GuildManager, error)
func (*GuildManager) AddHandler ¶
func (mng *GuildManager) AddHandler(handler interface{})
AddHandler is a wrapper for the session handler but limits the handler to only the guild This may seem excessive but it is a good practice to prevent accidental checking of the wrong guild
func (*GuildManager) BotUser ¶
func (mng *GuildManager) BotUser() *discordgo.User
func (*GuildManager) CommandHandler ¶
func (mng *GuildManager) CommandHandler() *command.CommandHandler
func (*GuildManager) Connection ¶
func (mng *GuildManager) Connection() *gorm.DB
func (*GuildManager) GlobalManager ¶
func (mng *GuildManager) GlobalManager() *Manager
func (*GuildManager) Guild ¶
func (mng *GuildManager) Guild() *discordgo.Guild
func (*GuildManager) ListenForComponent ¶
func (mng *GuildManager) ListenForComponent(customId string, handler component.ComponentHandlerFunc)
func (*GuildManager) Logger ¶
func (mng *GuildManager) Logger() log.Logger
func (*GuildManager) ModalHandler ¶
func (mng *GuildManager) ModalHandler() *modal.ModalHandler
func (*GuildManager) Save ¶
func (mng *GuildManager) Save() error
func (*GuildManager) Session ¶
func (mng *GuildManager) Session() *discordgo.Session
func (*GuildManager) Start ¶
func (mng *GuildManager) Start() error
func (*GuildManager) Stop ¶
func (mng *GuildManager) Stop() error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the overarching structure that manages all of the guild sub-services Moreover, it holds the database connection and handles all Discord events
func (*Manager) Connection ¶
func (*Manager) CreateServices ¶
func (mng *Manager) CreateServices(guildManager *GuildManager) []Service
CreateServices creates a service for a provided guild manager
func (*Manager) GuildExists ¶
func (*Manager) GuildManager ¶
func (mng *Manager) GuildManager(guildID string) (*GuildManager, error)
func (*Manager) OnStart ¶
func (mng *Manager) OnStart(f ManagerStartFunc)
func (*Manager) RegisterService ¶
RegisterService registers a service to be created when the manager starts In most cases, an empty struct should be passed in as the argument This is because the actual guild services will be created using service.Create()
type ManagerStartFunc ¶
type Service ¶
type Service interface {
// Name returns the name of the service
Name() string
// Create creates a new instance of the service for a provided guild manager
Create(mng *GuildManager) (Service, error)
// Start is called when the service is started
Start(mng *GuildManager) error
// Stop is called when the service is stopped
Stop(mng *GuildManager) error
}
Service is the interface that all services must implement It defines the methods that are called when the service is started or stopped
type StringArray ¶
type StringArray []string
StringArray is a wrapper around []string that implements the sql.Scanner and driver.Valuer interfaces
func (*StringArray) Scan ¶
func (a *StringArray) Scan(value any) error
type Timestamp ¶
Timestamp represents a Discord timestamp in milliseconds