Documentation ¶
Index ¶
- Constants
- Variables
- type ChannelBasedPrompt
- type ChannelBasedReactionPrompt
- type ChannelBasedReactionTogglePrompt
- type Command
- type Config
- type DMChannelCache
- type Database
- type ErrInsufficientBotPermissions
- type ErrInsufficientPermissions
- type ErrMissingArgs
- type ErrNeedsNSFWChannel
- type ErrNotOwner
- type Event
- type PromptStatus
- type Session
- func (s *Session) CheckChannelPermission(userID string, channelID string, permission int) bool
- func (s *Session) CheckMemberPermission(userID string, guildID string, permission int) bool
- func (s *Session) CreateDMChannelCached(userID string) (string, error)
- func (s *Session) DownloadMembers(guildID string, onReceivePage func(st []*discordgo.Member) (shouldStop bool)) error
- func (s *Session) FetchChannel(id string) (*discordgo.Channel, error)
- func (s *Session) FetchEmoji(emojiID string) (*discordgo.Emoji, bool)
- func (s *Session) FetchGuild(id string) (*discordgo.Guild, error)
- func (s *Session) FetchGuildUser(guildID string, id string) (*discordgo.User, error)
- func (s *Session) FetchGuildUserCached(guildID string, id string) (*discordgo.User, error)
- func (s *Session) FetchMember(guildID string, id string) (*discordgo.Member, error)
- func (s *Session) FetchRole(guildID string, id string) (*discordgo.Role, error)
- func (s *Session) FetchUser(id string) (*discordgo.User, error)
- func (s *Session) GetMember(query string, guildID string) (*discordgo.Member, error)
- func (s *Session) GetMemberStrict(query string, guildID string) (*discordgo.Member, error)
- func (s *Session) GetPrompt(userID string) (prompt *ChannelBasedPrompt, ok bool)
- func (s *Session) GetReactionPrompt(userID string) (prompt *ChannelBasedReactionPrompt, ok bool)
- func (s *Session) GetReactionTogglePrompt(userID string) (prompt *ChannelBasedReactionTogglePrompt, ok bool)
- func (s *Session) GetRole(query string, guild *discordgo.Guild, allowNames bool) (*discordgo.Role, error)
- func (s *Session) GetRoles(query string, guild *discordgo.Guild) ([]*discordgo.Role, error)
- func (s *Session) GuildRoleEditMentionable(guildID string, roleID string, mention bool) (st *discordgo.Role, err error)
- func (s *Session) Open() (err error)
- func (s *Session) Prompt(timeout time.Duration, userID string, channelID string) (PromptStatus, *discordgo.Message)
- func (s *Session) PromptChannel(timeout time.Duration, userID string, channelID string) *ChannelBasedPrompt
- func (s *Session) PromptReaction(timeout time.Duration, userID string, messageID string) (PromptStatus, *discordgo.MessageReaction)
- func (s *Session) PromptReactionChannel(timeout time.Duration, userID string, messageID string) *ChannelBasedReactionPrompt
- func (s *Session) PromptReactionToggle(timeout time.Duration, userID string, messageID string) (PromptStatus, *discordgo.MessageReaction)
- func (s *Session) PromptReactionToggleChannel(timeout time.Duration, userID string, messageID string) *ChannelBasedReactionTogglePrompt
- type UserCache
Constants ¶
const VERSION = "0.6.2"
VERSION of tranquility, follows semantic versioning.
Variables ¶
ErrGuildIsUnavailable throws when a function is called on an unavailable guild
var ErrMemberNotFound = errors.New("member not found")
ErrMemberNotFound throws when a member isn't found
var ErrRoleNotFound = errors.New("role not found")
ErrRoleNotFound throws when a role is not found
var ErrTooManyRoles = errors.New("too many roles with one name")
ErrTooManyRoles throws when there are more than 1 role with the same name
Functions ¶
This section is empty.
Types ¶
type ChannelBasedPrompt ¶ added in v0.1.1
type ChannelBasedPrompt struct { ChannelID string // OutputChan is where messages can be received. // For sending reactions to this channel, use Send() instead. OutputChan chan *discordgo.Message TimeoutChan <-chan time.Time // contains filtered or unexported fields }
ChannelBasedPrompt is a channel-based prompt
func (*ChannelBasedPrompt) Dispose ¶ added in v0.1.1
func (c *ChannelBasedPrompt) Dispose()
Dispose disposes of the prompt gracefully
func (*ChannelBasedPrompt) Send ¶ added in v0.4.2
func (c *ChannelBasedPrompt) Send(m *discordgo.Message)
Send sends a message to the prompt
type ChannelBasedReactionPrompt ¶ added in v0.1.1
type ChannelBasedReactionPrompt struct { MessageID string // OutputChan is where reactions can be received. // For sending reactions to this channel, use Send() instead. OutputChan chan *discordgo.MessageReaction TimeoutChan <-chan time.Time // contains filtered or unexported fields }
ChannelBasedReactionPrompt is a channel-based reaction prompt
func (*ChannelBasedReactionPrompt) Dispose ¶ added in v0.1.1
func (c *ChannelBasedReactionPrompt) Dispose()
Dispose disposes of the prompt gracefully
func (*ChannelBasedReactionPrompt) Send ¶ added in v0.4.2
func (c *ChannelBasedReactionPrompt) Send(r *discordgo.MessageReaction)
Send sends a reaction to the prompt
type ChannelBasedReactionTogglePrompt ¶ added in v0.1.1
type ChannelBasedReactionTogglePrompt struct { MessageID string // OutputChan is where reactions can be received. // For sending reactions to this channel, use Send() instead. OutputChan chan *discordgo.MessageReaction TimeoutChan <-chan time.Time // contains filtered or unexported fields }
ChannelBasedReactionTogglePrompt is a channel-based reaction toggle prompt
func (*ChannelBasedReactionTogglePrompt) Dispose ¶ added in v0.1.1
func (c *ChannelBasedReactionTogglePrompt) Dispose()
Dispose disposes of the prompt gracefully
func (*ChannelBasedReactionTogglePrompt) Send ¶ added in v0.4.2
func (c *ChannelBasedReactionTogglePrompt) Send(r *discordgo.MessageReaction)
Send sends a reaction to the prompt
type Command ¶
type Command struct { // Names that can be used to get the command Names []string // Called when the bot first starts up. Init func(commands []*Command, commandsMap *map[string]*Command) error // Called when the bot has established a connection to Discord. Ready func(s *Session) error // Called when a user invokes this command. // This function assumes the length of args to be >= ArgCount, and as such // should only be called after checking len(*args). Run func(e *Event, m *discordgo.Message, args []string) *discordgo.MessageSend // Subcommands SubCmds []*Command // Minimum amount of arguments required ArgCount int // Argument names. // Only used for `help` command. // len(Args) must always >= ArgCount. Args []string Category int // Description of this command Desc string // Whether only the owner should be able to invoke this command Own bool // Whether this command is NSFW NSFW bool // Permission required for running the command Perms []int BotPerms []int }
Command represents a command
type DMChannelCache ¶ added in v0.1.1
type DMChannelCache struct {
// contains filtered or unexported fields
}
DMChannelCache represents a user cache
func NewDMChannelCache ¶ added in v0.1.1
func NewDMChannelCache(s *Session) *DMChannelCache
NewDMChannelCache returns a new UserCache instance
func (*DMChannelCache) CreateDMChannel ¶ added in v0.1.1
func (cc *DMChannelCache) CreateDMChannel(userID string) (string, error)
CreateDMChannel returns the DM channel ID of the user
type Database ¶
Database is a Bolt database with utilities
func (*Database) ListBuckets ¶
ListBuckets returns a list of all buckets
type ErrInsufficientBotPermissions ¶
type ErrInsufficientBotPermissions struct {
ErrInsufficientPermissions
}
ErrInsufficientBotPermissions throws when the bot does not have sufficient permissions
func (*ErrInsufficientBotPermissions) Error ¶
func (*ErrInsufficientBotPermissions) Error() string
type ErrInsufficientPermissions ¶
type ErrInsufficientPermissions struct{}
ErrInsufficientPermissions throws when the user does not have sufficient permissions
func (*ErrInsufficientPermissions) Error ¶
func (*ErrInsufficientPermissions) Error() string
type ErrMissingArgs ¶
ErrMissingArgs throws when not enough arguments are supplied
func (*ErrMissingArgs) Error ¶
func (*ErrMissingArgs) Error() string
type ErrNeedsNSFWChannel ¶
type ErrNeedsNSFWChannel struct{}
ErrNeedsNSFWChannel throws when a NSFW command is used inside a non-NSFW channel
func (*ErrNeedsNSFWChannel) Error ¶
func (*ErrNeedsNSFWChannel) Error() string
type ErrNotOwner ¶
type ErrNotOwner struct{}
ErrNotOwner throws when an owner-only command is used by a non-owner
func (*ErrNotOwner) Error ¶
func (*ErrNotOwner) Error() string
type Event ¶
type Event struct { // The discordgo session Session *Session // The prefix in the context of the message that ran the command Prefix string // The command name used to identify the command CommandName []string }
Event represents an event sent to a command function
type PromptStatus ¶
type PromptStatus int
PromptStatus represents the prompt's finish status
const ( // Success means the prompt is successful Success PromptStatus = iota // Timeout means the prompt timed out Timeout // Fail means the prompt was overriden and you should cancel the command Fail )
func (PromptStatus) IsSuccess ¶
func (s PromptStatus) IsSuccess() bool
IsSuccess returns whether the prompt was successful
type Session ¶
type Session struct { *discordgo.Session StartTime time.Time SelfMentions []string // contains filtered or unexported fields }
Session is a discordgo session with utilities
func NewSession ¶
NewSession returns a session
func (*Session) CheckChannelPermission ¶
CheckChannelPermission checks if a member has a permission in a channel
func (*Session) CheckMemberPermission ¶
CheckMemberPermission checks if a member has a permission
func (*Session) CreateDMChannelCached ¶ added in v0.1.1
CreateDMChannelCached fetches a DM channel by user ID, using a cache to reduce network traffic.
func (*Session) DownloadMembers ¶ added in v0.5.0
func (s *Session) DownloadMembers(guildID string, onReceivePage func(st []*discordgo.Member) (shouldStop bool)) error
DownloadMembers downloads all members from the guild
func (*Session) FetchChannel ¶
FetchChannel fetches a channel by ID
func (*Session) FetchEmoji ¶
FetchEmoji returns an emoji under the specified ID
func (*Session) FetchGuild ¶
FetchGuild gets a guild by ID
func (*Session) FetchGuildUser ¶
FetchGuildUser fetches a user by ID in the specified guild's presences and falls back to FetchUser.
func (*Session) FetchGuildUserCached ¶
FetchGuildUserCached fetches a user by ID in the specified guild's presences and falls back to FetchUser, using a cache to reduce network traffic.
func (*Session) FetchMember ¶
FetchMember gets a guild member by ID
func (*Session) GetMemberStrict ¶
GetMemberStrict gets a member by ID or mention
func (*Session) GetPrompt ¶
func (s *Session) GetPrompt(userID string) (prompt *ChannelBasedPrompt, ok bool)
GetPrompt gets the prompt channel of the specified user ID
func (*Session) GetReactionPrompt ¶ added in v0.1.1
func (s *Session) GetReactionPrompt(userID string) (prompt *ChannelBasedReactionPrompt, ok bool)
GetReactionPrompt gets the prompt channel of the specified user ID
func (*Session) GetReactionTogglePrompt ¶ added in v0.1.1
func (s *Session) GetReactionTogglePrompt(userID string) (prompt *ChannelBasedReactionTogglePrompt, ok bool)
GetReactionTogglePrompt gets the prompt channel of the specified user ID
func (*Session) GetRole ¶
func (s *Session) GetRole(query string, guild *discordgo.Guild, allowNames bool) (*discordgo.Role, error)
GetRole gets a role by ID allowNames allows also getting a role by name
func (*Session) GuildRoleEditMentionable ¶
func (s *Session) GuildRoleEditMentionable(guildID string, roleID string, mention bool) (st *discordgo.Role, err error)
GuildRoleEditMentionable updates whether an existing Guild Role is mentionable
func (*Session) Prompt ¶
func (s *Session) Prompt(timeout time.Duration, userID string, channelID string) (PromptStatus, *discordgo.Message)
Prompt prompts the user. The returned Message is nil unless the returned status is Success.
func (*Session) PromptChannel ¶ added in v0.1.1
func (s *Session) PromptChannel(timeout time.Duration, userID string, channelID string) *ChannelBasedPrompt
PromptChannel creates a channel-based prompt
func (*Session) PromptReaction ¶ added in v0.1.1
func (s *Session) PromptReaction(timeout time.Duration, userID string, messageID string) (PromptStatus, *discordgo.MessageReaction)
PromptReaction prompts the user's reaction. The returned MessageReaction is nil unless the returned status is Success.
func (*Session) PromptReactionChannel ¶ added in v0.1.1
func (s *Session) PromptReactionChannel(timeout time.Duration, userID string, messageID string) *ChannelBasedReactionPrompt
PromptReactionChannel creates a channel-based reaction prompt
func (*Session) PromptReactionToggle ¶ added in v0.1.1
func (s *Session) PromptReactionToggle(timeout time.Duration, userID string, messageID string) (PromptStatus, *discordgo.MessageReaction)
PromptReactionToggle prompts the user's reaction toggle. The returned MessageReaction is nil unless the returned status is Success.
func (*Session) PromptReactionToggleChannel ¶ added in v0.1.1
func (s *Session) PromptReactionToggleChannel(timeout time.Duration, userID string, messageID string) *ChannelBasedReactionTogglePrompt
PromptReactionToggleChannel creates a channel-based reaction toggle prompt
type UserCache ¶
type UserCache struct {
// contains filtered or unexported fields
}
UserCache represents a user cache
func NewUserCache ¶
NewUserCache returns a new UserCache instance