69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package bolt
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
dg "github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
// the message struct is passed to the command payload providing basic
|
|
// message information and needed methods
|
|
type Message struct {
|
|
Author string //username of message author
|
|
ID string //discord ID of message author
|
|
msgID string //id string of message
|
|
Words []string //words from message split on whitespace
|
|
Content string //entire message content
|
|
Channel string //message channel
|
|
channelID string //id of channel message was sent in
|
|
Server string //message guild
|
|
serverID string //id of guild message was sent in
|
|
Attachments []MessageAttachment
|
|
sesh *bolt
|
|
}
|
|
|
|
// applies reaction to message
|
|
func (m *Message) React(emoji Reaction) error {
|
|
return m.sesh.MessageReactionAdd(m.channelID, m.msgID, fmt.Sprint(emoji))
|
|
}
|
|
|
|
// sends response to message
|
|
func (m *Message) Respond(res string) error {
|
|
rep := m.sesh.createReply(res, m.msgID, m.channelID, m.serverID)
|
|
_, err := m.sesh.ChannelMessageSendComplex(m.channelID, rep)
|
|
return err
|
|
}
|
|
|
|
// deletes the message from the channel
|
|
func (m *Message) Delete() error {
|
|
return m.sesh.ChannelMessageDelete(m.channelID, m.msgID, nil)
|
|
}
|
|
|
|
// this struct has all of the needed information from the messageCreate event so that
|
|
// commands can be run asynchronously. Passing the messageCreate to payloads can block routines
|
|
type MessageCreateEvent struct {
|
|
AuthorUsername string
|
|
AuthorID string
|
|
AuthorRoles []string
|
|
MsgID string
|
|
Msg string
|
|
MsgChanID string
|
|
MsgChanName string
|
|
MsgGuildID string
|
|
MsgGuildName string
|
|
MsgAttachments []*dg.MessageAttachment
|
|
}
|
|
|
|
// message attachment details
|
|
type MessageAttachment struct {
|
|
ID string
|
|
URL string
|
|
ProxyURL string
|
|
Filename string
|
|
ContentType string
|
|
Width int
|
|
Height int
|
|
Size int
|
|
DurationSecs float64
|
|
}
|