Documentation
¶
Index ¶
- Constants
- type Manager
- func (m *Manager) AddHandler(handler interface{})
- func (m *Manager) ApplicationCommandBulkOverwrite(guildID string, cmds []*discordgo.ApplicationCommand) (errs []error)
- func (m *Manager) ApplicationCommandCreate(guildID string, cmd *discordgo.ApplicationCommand) (errs []error)
- func (m *Manager) ApplicationCommandDelete(guildID string, cmd *discordgo.ApplicationCommand) (errs []error)
- func (m *Manager) GuildCount() (count int)
- func (m *Manager) RegisterIntent(intent discordgo.Intent)
- func (m *Manager) Restart() (nMgr *Manager, err error)
- func (m *Manager) SessionForDM() *discordgo.Session
- func (m *Manager) SessionForGuild(guildID int64) *discordgo.Session
- func (m *Manager) SetShardCount(count int)
- func (m *Manager) Shutdown() (err error)
- func (m *Manager) Start() (err error)
- type Shard
- func (s *Shard) AddHandler(handler interface{})
- func (s *Shard) ApplicationCommandBulkOverwrite(guildID string, cmds []*discordgo.ApplicationCommand) error
- func (s *Shard) ApplicationCommandCreate(guildID string, cmd *discordgo.ApplicationCommand) error
- func (s *Shard) ApplicationCommandDelete(guildID string, cmd *discordgo.ApplicationCommand) error
- func (s *Shard) GuildCount() (count int)
- func (s *Shard) Init(token string, ID, ShardCount int, intent discordgo.Intent) (err error)
- func (s *Shard) Stop() (err error)
Constants ¶
const ( // TIMELIMIT specifies how long to pause between connecting shards. TIMELIMIT = time.Millisecond * 500 // VERSION specifies the shards module version. Follows semantic versioning (semver.org). VERSION = "2.4.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { sync.RWMutex // Discord gateway. Gateway *discordgo.Session // Discord intent. Intent discordgo.Intent // Shards managed by this Manager. Shards []*Shard // Total Shard count. ShardCount int // contains filtered or unexported fields }
Manager facilitates the management of Shards.
func New ¶
New creates a new Manager with the recommended number of shards. After calling New, call Start to begin connecting the shards.
Example: mgr := shards.New("Bot TOKEN")
func (*Manager) AddHandler ¶
func (m *Manager) AddHandler(handler interface{})
AddHandler registers an event handler for all Shards.
func (*Manager) ApplicationCommandBulkOverwrite ¶
func (m *Manager) ApplicationCommandBulkOverwrite(guildID string, cmds []*discordgo.ApplicationCommand) (errs []error)
ApplicationCommandBulkOverwrite registers a series of application commands for all Shards, overwriting existing commands.
func (*Manager) ApplicationCommandCreate ¶
func (m *Manager) ApplicationCommandCreate(guildID string, cmd *discordgo.ApplicationCommand) (errs []error)
ApplicationCommandCreate registers an application command for all Shards.
func (*Manager) ApplicationCommandDelete ¶
func (m *Manager) ApplicationCommandDelete(guildID string, cmd *discordgo.ApplicationCommand) (errs []error)
ApplicationCommandDelete deregisters an application command for all Shards.
func (*Manager) GuildCount ¶
GuildCount returns the amount of guilds that a Manager's Shards are handling.
func (*Manager) RegisterIntent ¶
RegisterIntent sets the Intent for all Shards' sessions.
func (*Manager) Restart ¶
Restart restarts the Manager, and rescales if necessary, all with zero downtime.
func (*Manager) SessionForDM ¶
SessionForDM returns the proper session for sending and receiving DM's.
func (*Manager) SessionForGuild ¶
SessionForGuild returns the proper session for the specified guild.
func (*Manager) SetShardCount ¶
SetShardCount sets the shard count. The new shard count won't take effect until the Manager is restarted.
type Shard ¶
type Shard struct { sync.RWMutex // The Discord session handling this Shard. Session *discordgo.Session // This Shard's ID. ID int // Total Shard count. ShardCount int // contains filtered or unexported fields }
A Shard represents a shard.
func (*Shard) AddHandler ¶
func (s *Shard) AddHandler(handler interface{})
AddHandler registers an event handler for a Shard.
Shouldn't be called after Init or results in undefined behavior.
func (*Shard) ApplicationCommandBulkOverwrite ¶
func (s *Shard) ApplicationCommandBulkOverwrite(guildID string, cmds []*discordgo.ApplicationCommand) error
ApplicationCommandBulkOverwrite registers a series of application commands for a Shard, overwriting existing commands.
Shouldn't be called before Initialization.
func (*Shard) ApplicationCommandCreate ¶
func (s *Shard) ApplicationCommandCreate(guildID string, cmd *discordgo.ApplicationCommand) error
ApplicationCommandCreate registers an application command for a Shard.
Shouldn't be called before Initialization.
func (*Shard) ApplicationCommandDelete ¶
func (s *Shard) ApplicationCommandDelete(guildID string, cmd *discordgo.ApplicationCommand) error
ApplicationCommandDelete deregisters an application command for a Shard.
Shouldn't be called before Initialization.
func (*Shard) GuildCount ¶
GuildCount returns the amount of guilds that a Shard is handling.