adding reaction support (#2)

- some rework of structure to allow for more puposeful response usage
- react and response now live on the message itself
- message structs split into own file
- readme updated to use new methods

Reviewed-on: #2
Co-authored-by: jake <jake.young.dev@gmail.com>
Co-committed-by: jake <jake.young.dev@gmail.com>
This commit is contained in:
2025-07-09 20:11:12 +00:00
committed by jake
parent 113fcbf2d1
commit 90a17ded2b
4 changed files with 144 additions and 52 deletions

56
bolt.go
View File

@@ -126,10 +126,10 @@ func (b *bolt) messageHandler(s *dg.Session, msg *dg.MessageCreate) {
return
}
//if there is no content it is likely an image or a GIF, updating message content for
//if there is no content it is likely an image, gif, or sticker, updating message content for
//better logging and to avoid confusion
if len(msg.Content) == 0 {
msg.Content = "GIF/IMAGE"
msg.Content = "[Embedded Content]"
}
if b.logLvl == LogLevelAll {
@@ -190,27 +190,43 @@ func (b *bolt) handleCommand(msg *dg.MessageCreate, s *dg.Session, server *dg.Gu
}
}
//run command payload
res, err := run.Payload(Message{
Author: msg.Author.Username,
ID: msg.Author.ID,
Words: words,
Content: msg.Content,
Channel: channel.Name,
Server: server.Name,
})
if err != nil {
return err
plMsg := Message{
Author: msg.Author.Username,
ID: msg.Author.ID,
msgID: msg.ID,
Words: words,
Content: msg.Content,
Channel: channel.Name,
channelID: msg.ChannelID,
Server: server.Name,
serverID: server.ID,
sesh: b,
}
//if a reply is returned send back to Discord
if res != "" {
reply := b.createReply(res, msg.ID, msg.ChannelID, msg.GuildID)
_, err := s.ChannelMessageSendComplex(msg.ChannelID, reply)
if err != nil {
return err
//check for file attachments
if len(msg.Attachments) > 0 {
var att []MessageAttachment
for _, a := range msg.Attachments {
att = append(att, MessageAttachment{
ID: a.ID,
URL: a.URL,
ProxyURL: a.ProxyURL,
Filename: a.Filename,
ContentType: a.ContentType,
Width: a.Width,
Height: a.Height,
Size: a.Size,
DurationSecs: a.DurationSecs,
})
}
plMsg.Attachments = att
}
//run command payload
err = run.Payload(plMsg)
if err != nil {
return err
}
//update run time