Documentation
¶
Index ¶
- Constants
- type Author
- type Bolt
- type Command
- type Context
- func (c *Context) ClearTimeout(userId string) error
- func (c *Context) Delete() error
- func (c *Context) Mute(userId string) error
- func (c *Context) React(emoji Reaction) error
- func (c *Context) Respond(res string) error
- func (c *Context) Timeout(userId string, duration time.Time) error
- func (c *Context) Unmute(userId string) error
- type LogLevel
- type Message
- type MessageAttachment
- type Option
- type Payload
- type Reaction
Constants ¶
const ( //the name of the environment variable that should contain the token for the bot, it is //required for bolt to run TOKEN_ENV_VAR = "DISCORD_TOKEN" //bot default command indicator, if messages begin with this substring they are processed //through the command handler instead of the generic message handler DEFAULT_INDICATOR = "." //max amount of concurrent goroutines that bolt can use for events. A lower amount //may lower the resource usage of bolt but may cause a delay in event handling DEFAULT_MAX_GOROUTINES = 250 //minimum intents for bots to function, intents can be changed with options DEFAULT_INTENTS = dg.IntentGuilds | dg.IntentGuildMembers | dg.IntentGuildPresences | dg.IntentMessageContent | dg.IntentsGuildMessages | dg.IntentGuildMessageReactions )
const ( // the max length allowed for basic messages, if the message content exceeds this amount // then messages are split unto chunks of max size MSG_MAX_LENGTH = 2000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bolt ¶
type Command ¶
type Command struct {
//the trigger phrase for the command, this field cannot include the command indicator. If the command is .ping
//Trigger should be "ping"
Trigger string
//handler function to run when command is detected
Payload Payload
//the amount of time that must pass before a command can be run again
Timeout time.Duration
//the roles that are allowed to execute this command, the command author must have at least one of these roles
//in order to use the command
Roles []string
// contains filtered or unexported fields
}
Command represents a bolt command in its entirety
type Context ¶ added in v0.6.0
type Context struct {
Message *Message
// contains filtered or unexported fields
}
Context is the struct passed to message and command handlers, it contains all needed message data as well as some methods to make interaction with the message as easy as possible
func (*Context) ClearTimeout ¶ added in v0.6.0
ClearTimeout clears existing user timeouts, allowing them access again
func (*Context) Mute ¶ added in v0.6.0
Mute handles muting a user from Voice Chat, this mute stays until it is Unmute()'d
func (*Context) Respond ¶ added in v0.6.0
Respond sends a response to the message, handling chunking if the message exceeds max length
type Message ¶
type Message struct {
Author Author
//current message ID
ID string
//message content split on whitespace to allow for easy argument parsing with commands
Words []string
//entire message content unchanged
Content string
//channel message was sent in, name and ID
Channel string
ChannelID string
//guild message was sent in, name and ID
Server string
ServerID string
//message extras
Attachments []MessageAttachment //any attachments bound to the message
Mentions []*dg.User //users mention in the message with @
}
Message contains all needed data to handle message events
type MessageAttachment ¶ added in v0.4.0
type Option ¶
type Option func(b *bolt)
func WithIndicator ¶
WithIndicator sets the substring that must be present at the beginning of a message to trigger a command, for example "." or "!"
func WithIntents ¶ added in v0.6.0
WithIntents provides an option to use custom intents for the bot. Bolt comes preconfigured with the basic intents needed to run a bot but those are completely overwritten by any supplied here
func WithLogLevel ¶ added in v0.3.0
WithLogLevel adjusts bolt logging verbosity
func WithMaxGoroutines ¶ added in v0.6.0
WithMaxGoroutines limits the amount of handler routines the bot is able to spawn at the same time. A lower value may cause higher latency but may reduce resources needed to run bolt
type Reaction ¶ added in v0.4.0
type Reaction string
const ( ReactionThumbsUp Reaction = "👍" ReactionThumbsDown Reaction = "👎" ReactionHundred Reaction = "💯" ReactionHeart Reaction = "❤️" ReactionPinkHeart Reaction = "🩷" ReactionOrangeHeart Reaction = "🧡" ReactionYellowHeart Reaction = "💛" ReactionGreenHeart Reaction = "💚" ReactionBlueHeart Reaction = "💙" ReactionBlackHeart Reaction = "🖤" ReactionPointUp Reaction = "☝️" ReactionPointDown Reaction = "👇" ReactionHotdog Reaction = "🌭" ReactionDog Reaction = "🐶" ReactionCat Reaction = "🐱" ReactionMonkey Reaction = "🐒" ReactionGiraffe Reaction = "🦒" ReactionDuck Reaction = "🦆" ReactionGoose Reaction = "🪿" ReactionWatermelon Reaction = "🍉" ReactionHoney Reaction = "🍯" ReactionSandwich Reaction = "🥪" ReactionPepper Reaction = "🌶️" ReactionNoPedestrians Reaction = "🚷" ReactionExclamation Reaction = "❗" ReactionDoubleExclamation Reaction = "‼️" ReactionSkull Reaction = "💀" ReactionSpeakingHead Reaction = "🗣️" ReactionGreenCheck Reaction = "✅" ReactionDragon Reaction = "🐉" )
a few easy-to-use emojis, Discordgo/Discord API requires them to be saved like this. Some appear "broken" but do not play friendly when saved in-file