3 Commits

Author SHA1 Message Date
7376e8f857 Merge pull request 'new/message-deletes' (#5) from new/message-deletes into main
Reviewed-on: #5
2025-09-08 21:05:53 +00:00
c196e25e0c update readme 2025-09-08 17:02:22 -04:00
d70dd8c3a4 updates
- moved reaction to own file
- added message delete method
2025-09-07 01:10:48 -04:00
3 changed files with 78 additions and 66 deletions

View File

@@ -44,6 +44,10 @@ The React method will react to the command message by adding the requested emoji
func (m *Message) Respond(res string) error
```
The Respond method will send the value of <b>res</b> in response to the command message.
```go
func Delete() error
```
The Delete method will delete the message from the text channel
### Example
```go

View File

@@ -6,71 +6,8 @@ import (
dg "github.com/bwmarrin/discordgo"
)
// built-in Discord reactions
type Reaction string
// a few easy-to-use emojis, Discordgo/Discord API requires them to be saved like this.
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 = "🐉"
)
// struct containing message event fields to prevent passing MessageCreate events and holding up 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
}
// information about attachments to messages
type MessageAttachment struct {
ID string
URL string
ProxyURL string
Filename string
ContentType string
Width int
Height int
Size int
DurationSecs float64
}
// represents a Discord message
// 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
@@ -90,9 +27,42 @@ func (m *Message) React(emoji Reaction) error {
return m.sesh.MessageReactionAdd(m.channelID, m.msgID, fmt.Sprint(emoji))
}
// sends the value of res in response to the message
// 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
}

38
reaction.go Normal file
View File

@@ -0,0 +1,38 @@
package bolt
// built-in Discord reactions
type Reaction string
// a few easy-to-use emojis, Discordgo/Discord API requires them to be saved like this.
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 = "🐉"
)