botrest

package
v1.20.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2019 License: MIT Imports: 21 Imported by: 0

README

Provides access to bot state using a rest api to be accessed from e.g scripts or the webserver

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerError    = errors.New("botrest server is having issues")
	ErrCantFindServer = errors.New("can't find botrest server for provided shard")
)

Functions

func BotIsRunning

func BotIsRunning() bool

Returns wether the bot is running or not, (time since last sucessfull ping was less than 5 seconds)

func Get added in v1.6.0

func Get(shard int, url string, dest interface{}) error

func GetBotMember

func GetBotMember(guildID int64) (m *discordgo.Member, err error)

func GetChannelPermissions

func GetChannelPermissions(guildID, channelID int64) (perms int64, err error)

func GetGuild

func GetGuild(guildID int64) (g *discordgo.Guild, err error)

func GetMemberColors added in v1.6.0

func GetMemberColors(guildID int64, members ...int64) (m map[string]int, err error)

func GetMemberMultiGuild added in v1.17.0

func GetMemberMultiGuild(userID int64, guilds ...int64) (members []*discordgo.Member, err error)

func GetMembers

func GetMembers(guildID int64, members ...int64) (m []*discordgo.Member, err error)

func GetOnlineCount added in v1.4.1

func GetOnlineCount(guildID int64) (c int64, err error)

func GetServerAddrForGuild added in v1.11.0

func GetServerAddrForGuild(guildID int64) string

func GetServerAddrForShard added in v1.11.0

func GetServerAddrForShard(shard int) string

func GetWithAddress added in v1.11.0

func GetWithAddress(addr string, url string, dest interface{}) error

func HandleBotMember

func HandleBotMember(w http.ResponseWriter, r *http.Request)

func HandleChannelPermissions

func HandleChannelPermissions(w http.ResponseWriter, r *http.Request)

func HandleGWStatus

func HandleGWStatus(w http.ResponseWriter, r *http.Request)

func HandleGetMemberColors added in v1.6.0

func HandleGetMemberColors(w http.ResponseWriter, r *http.Request)

func HandleGetMembers

func HandleGetMembers(w http.ResponseWriter, r *http.Request)

func HandleGetOnlineCount added in v1.4.1

func HandleGetOnlineCount(w http.ResponseWriter, r *http.Request)

func HandleGuild

func HandleGuild(w http.ResponseWriter, r *http.Request)

func HandlePing

func HandlePing(w http.ResponseWriter, r *http.Request)

func HandleReconnectShard

func HandleReconnectShard(w http.ResponseWriter, r *http.Request)

func Post added in v1.6.0

func Post(shard int, url string, bodyData interface{}, dest interface{}) error

func RedisKeyNodeAddressMapping added in v1.11.0

func RedisKeyNodeAddressMapping(nodeID string) string

func RedisKeyShardAddressMapping added in v1.11.0

func RedisKeyShardAddressMapping(shardID int) string

func RegisterPlugin added in v1.4.1

func RegisterPlugin()

func RestartAll added in v1.4.1

func RestartAll(reidentify bool)

func RunPinger

func RunPinger()

func SendReconnectAll added in v1.4.1

func SendReconnectAll(reidentify bool) (err error)

func SendReconnectShard

func SendReconnectShard(shardID int, reidentify bool) (err error)

func ServeJson

func ServeJson(w http.ResponseWriter, r *http.Request, data interface{})

func ServerError

func ServerError(w http.ResponseWriter, r *http.Request, err error) bool

Returns true if an error occured

Types

type BotRestPlugin added in v1.6.0

type BotRestPlugin interface {
	InitBotRestServer(mux *goji.Mux)
}

type NodeStatus added in v1.11.0

type NodeStatus struct {
	ID     string
	Shards []*ShardStatus `json:"shards"`
}

func GetNodeStatuses added in v1.11.0

func GetNodeStatuses() (st []*NodeStatus, err error)

type Plugin added in v1.4.1

type Plugin struct {
	// contains filtered or unexported fields
}

func (*Plugin) BotInit added in v1.4.1

func (p *Plugin) BotInit()

func (*Plugin) PluginInfo added in v1.17.0

func (p *Plugin) PluginInfo() *common.PluginInfo

func (*Plugin) StopBot added in v1.4.1

func (p *Plugin) StopBot(wg *sync.WaitGroup)

type ShardStatus

type ShardStatus struct {
	ShardID         int     `json:"shard_id"`
	TotalEvents     int64   `json:"total_events"`
	EventsPerSecond float64 `json:"events_per_second"`

	ConnStatus discordgo.GatewayStatus `json:"conn_status"`

	LastHeartbeatSend time.Time `json:"last_heartbeat_send"`
	LastHeartbeatAck  time.Time `json:"last_heartbeat_ack"`
}

Jump to

Keyboard shortcuts

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