diff --git a/message.go b/message.go index 6d828f7..8efb9fe 100644 --- a/message.go +++ b/message.go @@ -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 +} diff --git a/reaction.go b/reaction.go new file mode 100644 index 0000000..dff112b --- /dev/null +++ b/reaction.go @@ -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 = "๐Ÿ‰" +)