Documentation
¶
Index ¶
- Variables
- type Channel
- type ChannelLock
- type Connections
- type Core
- func (bot *Core) ChannelDeleteHandler(channelHandler func(*discordgo.Session, *discordgo.ChannelDelete))
- func (bot *Core) ChannelLockCreate(cID string) (*ChannelLock, error)
- func (bot *Core) ChannelMemoryAdd(channel *discordgo.Channel)
- func (bot *Core) ChannelMemoryDelete(channel *discordgo.Channel)
- func (bot *Core) ChannelToSlice(guildID, infoType string) (channels []string)
- func (bot *Core) ChannelUpdateHandler(channelHandler func(*discordgo.Session, *discordgo.ChannelUpdate))
- func (bot *Core) ConnectionsReset() error
- func (bot *Core) GetChannel(cID string) *Channel
- func (bot *Core) GetConnections() (*Connections, error)
- func (bot *Core) GetGuild(gID string) *Guild
- func (bot *Core) GetGuildID(cID string) (string, error)
- func (bot *Core) GetGuildMembers(guildID string, userAmount int) ([]*discordgo.Member, error)
- func (bot *Core) GetMainChannel(gID string) *discordgo.Channel
- func (bot *Core) GuildCreateHandler(createHandler func(*discordgo.Session, *discordgo.GuildCreate))
- func (bot *Core) GuildMemberAddHandler(userHandler func(*discordgo.Session, *discordgo.GuildMemberAdd))
- func (bot *Core) GuildMemberRemoveHandler(userHandler func(*discordgo.Session, *discordgo.GuildMemberRemove))
- func (bot *Core) GuildMemberUpdateHandler(userHandler func(*discordgo.Session, *discordgo.GuildMemberUpdate))
- func (bot *Core) GuildRoleDeleteHandler(deleteHandler func(*discordgo.Session, *discordgo.GuildRoleDelete))
- func (bot *Core) GuildRoleUpdateHandler(updateHandler func(*discordgo.Session, *discordgo.GuildRoleUpdate))
- func (bot *Core) GuildToSlice(infoType string) (guilds []string)
- func (bot *Core) GuildsString() string
- func (bot *Core) MessageCreateHandler(msgHandler func(*discordgo.Session, *discordgo.MessageCreate))
- func (bot *Core) MessageUpdateHandler(msgHandler func(*discordgo.Session, *discordgo.MessageUpdate))
- func (bot *Core) SetMainChannel(gID, cID string) error
- func (bot *Core) SetMainGuild(gID string)
- func (bot *Core) SetNickname(gID, name string, append bool) error
- func (bot *Core) Start() error
- func (bot *Core) Stop() error
- func (bot *Core) UpdateConnections() error
- func (bot *Core) UserID(name string) (string, error)
- type Guild
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilToken = errors.New("token is not set") ErrNilHandler = errors.New("message handler not assigned") )
Error constants
var ( ErrNilGuilds = errors.New("godbot: bot.guilds is nil (bot may not be in guilds)") ErrNilChannels = errors.New("godbot: bot.channels is nil") ErrNilLinks = errors.New("godbot: bot.links is nil") ErrNotFound = errors.New("godbot: not found") )
Standard error messages
var ( ErrChannelNotLocked = errors.New("channel is not locked") ErrChannelLocked = errors.New("channel is locked") ErrNilChannelLock = errors.New("provided a nil channel lock") ErrBadChannel = errors.New("bad channel for operation") ErrBadGuild = errors.New("bad guild for operation") )
Constants for locked channels.
Functions ¶
This section is empty.
Types ¶
type ChannelLock ¶
type ChannelLock struct { Locked bool Session *discordgo.Session Guild *Guild Channel *Channel Roles []*discordgo.Role Overwrites []*discordgo.PermissionOverwrite Message *discordgo.Message }
ChannelLock holds Locking information for a Channel.
func (*ChannelLock) ChannelLock ¶
func (cl *ChannelLock) ChannelLock(alert bool) error
ChannelLock will lock a channel preventing @everyone typing.
func (*ChannelLock) ChannelUnlock ¶
func (cl *ChannelLock) ChannelUnlock() error
ChannelUnlock will unlock a channel allowing for @everyone to type.
type Connections ¶
type Connections struct { Links map[string][]*discordgo.Channel Guilds []*discordgo.Guild Channels []*discordgo.Channel }
Connections holds all connection data.
type Core ¶
type Core struct { sync.Mutex // User Information User *discordgo.User Username string Status string ID int Token string Stream bool Game string LiteMode bool // If it loads EVERYTHING. Ready *discordgo.Ready // Connection Information. Session *discordgo.Session ChannelMain *discordgo.Channel Channels []*discordgo.Channel GuildMain *discordgo.Guild Guilds []*discordgo.Guild // Link map: [guild ID] []*Channels Links map[string][]*discordgo.Channel Private []*discordgo.Channel // contains filtered or unexported fields }
Core is the basic structure of the bot.
func (*Core) ChannelDeleteHandler ¶
func (bot *Core) ChannelDeleteHandler(channelHandler func(*discordgo.Session, *discordgo.ChannelDelete))
ChannelDeleteHandler for an event where a channel is removed from a guild.
func (*Core) ChannelLockCreate ¶
func (bot *Core) ChannelLockCreate(cID string) (*ChannelLock, error)
ChannelLockCreate returns a ChannelLock struct.
func (*Core) ChannelMemoryAdd ¶
ChannelMemoryAdd will Add/Replace a channels structure in memory.
func (*Core) ChannelMemoryDelete ¶
ChannelMemoryDelete will remove a channel from the array of channels in memory.
func (*Core) ChannelToSlice ¶
ChannelToSlice grants a list of currently accessible channels for a particular guild. By default, it will return a list of IDs. Giving "name" for infoType will return a list of channel names.
func (*Core) ChannelUpdateHandler ¶
func (bot *Core) ChannelUpdateHandler(channelHandler func(*discordgo.Session, *discordgo.ChannelUpdate))
ChannelUpdateHandler for any events that update a channel.
func (*Core) ConnectionsReset ¶
ConnectionsReset sets the defaults for the bots connections.
func (*Core) GetChannel ¶
GetChannel gets a Channel struct based on Channel ID.
func (*Core) GetConnections ¶
func (bot *Core) GetConnections() (*Connections, error)
GetConnections returns the current connection structure.
func (*Core) GetGuildID ¶
GetGuildID gets the ID of a guild from a Channel ID.
func (*Core) GetGuildMembers ¶
GetGuildMembers returns EVERY user in a guild.
func (*Core) GetMainChannel ¶
GetMainChannel sets the main channel for the bot.
func (*Core) GuildCreateHandler ¶
func (bot *Core) GuildCreateHandler(createHandler func(*discordgo.Session, *discordgo.GuildCreate))
GuildCreateHandler assigns a function to deal with newly create guilds.
func (*Core) GuildMemberAddHandler ¶
func (bot *Core) GuildMemberAddHandler(userHandler func(*discordgo.Session, *discordgo.GuildMemberAdd))
GuildMemberAddHandler assigns a function to deal with newly joining users.
func (*Core) GuildMemberRemoveHandler ¶
func (bot *Core) GuildMemberRemoveHandler(userHandler func(*discordgo.Session, *discordgo.GuildMemberRemove))
GuildMemberRemoveHandler assigns a function to deal with leaving users.
func (*Core) GuildMemberUpdateHandler ¶
func (bot *Core) GuildMemberUpdateHandler(userHandler func(*discordgo.Session, *discordgo.GuildMemberUpdate))
GuildMemberUpdateHandler assigns a function to deal with updating users.
func (*Core) GuildRoleDeleteHandler ¶
func (bot *Core) GuildRoleDeleteHandler(deleteHandler func(*discordgo.Session, *discordgo.GuildRoleDelete))
GuildRoleDeleteHandler checks if guild roles are removed.
func (*Core) GuildRoleUpdateHandler ¶
func (bot *Core) GuildRoleUpdateHandler(updateHandler func(*discordgo.Session, *discordgo.GuildRoleUpdate))
GuildRoleUpdateHandler will process new updates for guild roles.
func (*Core) GuildToSlice ¶
GuildToSlice gives a list of current accessible Guild infoType defaults to Guild ID, if infoType is set to "name" it will return names. otherwise it will return the IDs.
func (*Core) GuildsString ¶
GuildsString converts the entire guild list into string format.
func (*Core) MessageCreateHandler ¶
func (bot *Core) MessageCreateHandler(msgHandler func(*discordgo.Session, *discordgo.MessageCreate))
MessageCreateHandler assigns a function to handle messages.
func (*Core) MessageUpdateHandler ¶
func (bot *Core) MessageUpdateHandler(msgHandler func(*discordgo.Session, *discordgo.MessageUpdate))
MessageUpdateHandler assigns a function to handle messages.
func (*Core) SetMainChannel ¶
SetMainChannel sets the channel to primarily sit in.
func (*Core) SetMainGuild ¶
SetMainGuild assigns the guild and channel to the main server.
func (*Core) SetNickname ¶
SetNickname will set the current name of the bot to the guild.
func (*Core) UpdateConnections ¶
UpdateConnections is a public wrapper queries discord for all information needed by bot.