Documentation ¶
Index ¶
- Constants
- Variables
- func AdminOrPerm(needed int, userID, channelID int64) (bool, error)
- func BotStarted()
- func ConcurrentEventHandler(inner eventsystem.Handler) eventsystem.Handler
- func ContextSession(ctx context.Context) *discordgo.Session
- func EmitGuildRemoved(guildID int64)
- func GetMember(guildID, userID int64) (*dstate.MemberState, error)
- func GetMembers(guildID int64, userIDs ...int64) ([]*dstate.MemberState, error)
- func GuildCountsFunc() []int
- func GuildName(gID int64) (name string)
- func HandleChannelCreate(evt *eventsystem.EventData)
- func HandleChannelDelete(evt *eventsystem.EventData)
- func HandleChannelUpdate(evt *eventsystem.EventData)
- func HandleGuildCreate(evt *eventsystem.EventData)
- func HandleGuildDelete(evt *eventsystem.EventData)
- func HandleGuildMemberUpdate(evt *eventsystem.EventData)
- func HandleGuildRoleCreate(evt *eventsystem.EventData)
- func HandleGuildRoleRemove(evt *eventsystem.EventData)
- func HandleGuildRoleUpdate(evt *eventsystem.EventData)
- func HandleGuildUpdate(evt *eventsystem.EventData)
- func HandleReady(data *eventsystem.EventData)
- func InitPlugins()
- func InvalidateCache(guildID, userID int64)
- func MonitorLoading()
- func QueueMergedMessage(channelID int64, message string)
- func Run()
- func SendDM(user int64, msg string) error
- func SendDMEmbed(user int64, embed *discordgo.MessageEmbed) error
- func SnowflakeToTime(i int64) time.Time
- func StateHandler(evt *eventsystem.EventData)
- func Stop(wg *sync.WaitGroup)
- func StopAllPlugins(wg *sync.WaitGroup)
- type BotInitHandler
- type BotStartedHandler
- type BotStopperHandler
- type DiscordMessages
- type MemberFetchGuildQueue
- type MemberFetchRequest
- type MemberFetchResult
- type NewGuildHandler
- type RemoveGuildHandler
- type ShardMigrationHandler
- type SlaveImpl
- func (s *SlaveImpl) FullStart()
- func (s *SlaveImpl) LoadGuildState(gs *master.GuildStateData)
- func (s *SlaveImpl) SendGuilds(shard int)
- func (s *SlaveImpl) Shutdown()
- func (s *SlaveImpl) SoftStart()
- func (s *SlaveImpl) StartShard(shard int, sessionID string, sequence int64)
- func (s *SlaveImpl) StartShardTransferFrom() int
- func (s *SlaveImpl) StartShardTransferTo(numShards int)
- func (s *SlaveImpl) StopShard(shard int) (sessionID string, sequence int64)
- type WrappedMessage
Constants ¶
const ( StateRunningNoMaster int = iota StateRunningWithMaster // Fully started StateWaitingHelloMaster StateSoftStarting StateShardMigrationTo StateShardMigrationFrom )
const EventLoggerPeriodDuration = time.Second * 10
const ( // How long after removing a guild the config for it gets cleared GuildRemoveConfigExpire = 60 * 60 * 24 // <- 1 day )
Variables ¶
var ( // When the bot was started Started = time.Now() Running bool State *dstate.State ShardManager *dshardmanager.Manager StateHandlerPtr *eventsystem.Handler SlaveClient *slave.Conn )
var ( ErrStartingUp = errors.New("Starting up, caches are being filled...") ErrGuildNotFound = errors.New("Guild not found") )
var (
Cache = cache.New(time.Minute, time.Minute)
)
var (
EventLogger = &eventLogger{}
)
var ( MemberFetcher = &memberFetcher{ fetching: make(map[int64]*MemberFetchGuildQueue), notFetching: make(map[int64]*MemberFetchGuildQueue), } )
Functions ¶
func BotStarted ¶ added in v1.4.1
func BotStarted()
func ConcurrentEventHandler ¶
func ConcurrentEventHandler(inner eventsystem.Handler) eventsystem.Handler
func EmitGuildRemoved ¶
func EmitGuildRemoved(guildID int64)
func GetMembers ¶
func GetMembers(guildID int64, userIDs ...int64) ([]*dstate.MemberState, error)
func GuildCountsFunc ¶
func GuildCountsFunc() []int
func GuildName ¶ added in v0.29.1
GuildName is a convenience function for getting the name of a guild
func HandleChannelCreate ¶
func HandleChannelCreate(evt *eventsystem.EventData)
func HandleChannelDelete ¶
func HandleChannelDelete(evt *eventsystem.EventData)
func HandleChannelUpdate ¶
func HandleChannelUpdate(evt *eventsystem.EventData)
func HandleGuildCreate ¶
func HandleGuildCreate(evt *eventsystem.EventData)
func HandleGuildDelete ¶
func HandleGuildDelete(evt *eventsystem.EventData)
func HandleGuildMemberUpdate ¶
func HandleGuildMemberUpdate(evt *eventsystem.EventData)
func HandleGuildRoleCreate ¶
func HandleGuildRoleCreate(evt *eventsystem.EventData)
func HandleGuildRoleRemove ¶
func HandleGuildRoleRemove(evt *eventsystem.EventData)
func HandleGuildRoleUpdate ¶
func HandleGuildRoleUpdate(evt *eventsystem.EventData)
func HandleGuildUpdate ¶
func HandleGuildUpdate(evt *eventsystem.EventData)
func HandleReady ¶
func HandleReady(data *eventsystem.EventData)
func InitPlugins ¶ added in v1.4.1
func InitPlugins()
func InvalidateCache ¶
func InvalidateCache(guildID, userID int64)
func MonitorLoading ¶
func MonitorLoading()
func QueueMergedMessage ¶
func SendDMEmbed ¶ added in v1.4.1
func SendDMEmbed(user int64, embed *discordgo.MessageEmbed) error
func SnowflakeToTime ¶ added in v1.4.1
func StateHandler ¶
func StateHandler(evt *eventsystem.EventData)
StateHandler updates the world state use AddHandlerBefore to add handler before this one, otherwise they will alwyas be after
func StopAllPlugins ¶ added in v1.4.1
Types ¶
type BotInitHandler ¶ added in v1.4.1
type BotInitHandler interface {
BotInit()
}
Fired when the bot it starting up, not for the webserver
type BotStartedHandler ¶
type BotStartedHandler interface {
BotStarted()
}
Fired after the bot has connected all shards
type BotStopperHandler ¶
type DiscordMessages ¶
type DiscordMessages []*dstate.MessageState
func (DiscordMessages) Len ¶
func (d DiscordMessages) Len() int
Len is the number of elements in the collection.
func (DiscordMessages) Less ¶
func (d DiscordMessages) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (DiscordMessages) Swap ¶
func (d DiscordMessages) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type MemberFetchGuildQueue ¶
type MemberFetchGuildQueue struct {
Queue []*MemberFetchRequest
}
type MemberFetchRequest ¶
type MemberFetchRequest struct { Member int64 Guild int64 WaitingChannels []chan MemberFetchResult }
type MemberFetchResult ¶
type MemberFetchResult struct { Err error Member *dstate.MemberState }
type NewGuildHandler ¶
Used for intializing stuff for new servers
type RemoveGuildHandler ¶
Used for deleting configuration about servers
type ShardMigrationHandler ¶ added in v1.4.1
type ShardMigrationHandler interface {
GuildMigrated(guild *dstate.GuildState, toThisSlave bool)
}
type SlaveImpl ¶ added in v1.4.1
type SlaveImpl struct{}
Slave implementation
func (*SlaveImpl) LoadGuildState ¶ added in v1.4.1
func (s *SlaveImpl) LoadGuildState(gs *master.GuildStateData)
func (*SlaveImpl) SendGuilds ¶ added in v1.4.1
func (*SlaveImpl) StartShard ¶ added in v1.4.1
func (*SlaveImpl) StartShardTransferFrom ¶ added in v1.4.1
func (*SlaveImpl) StartShardTransferTo ¶ added in v1.4.1
type WrappedMessage ¶
func GetMessages ¶
func GetMessages(channelID int64, limit int, deleted bool) ([]*WrappedMessage, error)
GetMessages Gets messages from state if possible, if not then it retrieves from the discord api Puts the messages in the state aswell