Skip to content

Commit

Permalink
Add super reactions (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 authored Aug 24, 2023
1 parent 16c4e0a commit cdef17e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 24 deletions.
18 changes: 13 additions & 5 deletions discord/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,19 @@ type MessageSticker struct {
FormatType StickerFormatType `json:"format_type"`
}

// MessageReaction contains information about the reactions of a message_events
// MessageReaction contains information about the reactions of a message
type MessageReaction struct {
Count int `json:"count"`
Me bool `json:"me"`
Emoji Emoji `json:"emoji"`
Count int `json:"count"`
CountDetails ReactionCountDetails `json:"count_details"`
Me bool `json:"me"`
MeBurst bool `json:"me_burst"`
Emoji Emoji `json:"emoji"`
BurstColors []string `json:"burst_colors"`
}

type ReactionCountDetails struct {
Burst int `json:"burst"`
Normal int `json:"normal"`
}

// MessageActivityType is the type of MessageActivity https://com/developers/docs/resources/channel#message-object-message-activity-types
Expand Down Expand Up @@ -387,7 +395,7 @@ type MessageReference struct {
FailIfNotExists bool `json:"fail_if_not_exists,omitempty"`
}

// MessageInteraction is sent on the Message object when the message_events is a response to an interaction
// MessageInteraction is sent on the Message object when the message is a response to an interaction
type MessageInteraction struct {
ID snowflake.ID `json:"id"`
Type InteractionType `json:"type"`
Expand Down
10 changes: 6 additions & 4 deletions events/dm_message_reaction_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
// GenericDMMessageReaction is called upon receiving DMMessageReactionAdd or DMMessageReactionRemove (requires the gateway.IntentDirectMessageReactions)
type GenericDMMessageReaction struct {
*GenericEvent
UserID snowflake.ID
ChannelID snowflake.ID
MessageID snowflake.ID
Emoji discord.PartialEmoji
UserID snowflake.ID
ChannelID snowflake.ID
MessageID snowflake.ID
Emoji discord.PartialEmoji
BurstColors []string
Burst bool
}

// DMMessageReactionAdd indicates that a discord.User added a discord.MessageReaction to a discord.Message in a Channel (requires the gateway.IntentDirectMessageReactions)
Expand Down
12 changes: 7 additions & 5 deletions events/guild_message_reaction_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
// GenericGuildMessageReaction is called upon receiving GuildMessageReactionAdd or GuildMessageReactionRemove
type GenericGuildMessageReaction struct {
*GenericEvent
UserID snowflake.ID
ChannelID snowflake.ID
MessageID snowflake.ID
GuildID snowflake.ID
Emoji discord.PartialEmoji
UserID snowflake.ID
ChannelID snowflake.ID
MessageID snowflake.ID
GuildID snowflake.ID
Emoji discord.PartialEmoji
BurstColors []string
Burst bool
}

// Member returns the Member that reacted to the discord.Message from the cache.
Expand Down
12 changes: 7 additions & 5 deletions events/message_reaction_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
// GenericReaction is called upon receiving MessageReactionAdd or MessageReactionRemove
type GenericReaction struct {
*GenericEvent
UserID snowflake.ID
ChannelID snowflake.ID
MessageID snowflake.ID
GuildID *snowflake.ID
Emoji discord.PartialEmoji
UserID snowflake.ID
ChannelID snowflake.ID
MessageID snowflake.ID
GuildID *snowflake.ID
Emoji discord.PartialEmoji
BurstColors []string
Burst bool
}

// MessageReactionAdd indicates that a discord.User added a discord.MessageReaction to a discord.Message in a discord.Channel(this+++ requires the gateway.IntentGuildMessageReactions and/or gateway.IntentDirectMessageReactions)
Expand Down
14 changes: 9 additions & 5 deletions gateway/gateway_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ type EventMessageReactionAdd struct {
Member *discord.Member `json:"member"`
Emoji discord.PartialEmoji `json:"emoji"`
MessageAuthorID *snowflake.ID `json:"message_author_id"`
BurstColors []string `json:"burst_colors"`
Burst bool `json:"burst"`
}

func (e *EventMessageReactionAdd) UnmarshalJSON(data []byte) error {
Expand All @@ -213,11 +215,13 @@ func (EventMessageReactionAdd) messageData() {}
func (EventMessageReactionAdd) eventData() {}

type EventMessageReactionRemove struct {
UserID snowflake.ID `json:"user_id"`
ChannelID snowflake.ID `json:"channel_id"`
MessageID snowflake.ID `json:"message_id"`
GuildID *snowflake.ID `json:"guild_id"`
Emoji discord.PartialEmoji `json:"emoji"`
UserID snowflake.ID `json:"user_id"`
ChannelID snowflake.ID `json:"channel_id"`
MessageID snowflake.ID `json:"message_id"`
GuildID *snowflake.ID `json:"guild_id"`
Emoji discord.PartialEmoji `json:"emoji"`
BurstColors []string `json:"burst_colors"`
Burst bool `json:"burst"`
}

func (EventMessageReactionRemove) messageData() {}
Expand Down
12 changes: 12 additions & 0 deletions handlers/message_reaction_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func gatewayHandlerMessageReactionAdd(client bot.Client, sequenceNumber int, sha
GuildID: event.GuildID,
UserID: event.UserID,
Emoji: event.Emoji,
BurstColors: event.BurstColors,
Burst: event.Burst,
},
Member: event.Member,
})
Expand All @@ -29,6 +31,8 @@ func gatewayHandlerMessageReactionAdd(client bot.Client, sequenceNumber int, sha
ChannelID: event.ChannelID,
UserID: event.UserID,
Emoji: event.Emoji,
BurstColors: event.BurstColors,
Burst: event.Burst,
},
MessageAuthorID: event.MessageAuthorID,
})
Expand All @@ -41,6 +45,8 @@ func gatewayHandlerMessageReactionAdd(client bot.Client, sequenceNumber int, sha
GuildID: *event.GuildID,
UserID: event.UserID,
Emoji: event.Emoji,
BurstColors: event.BurstColors,
Burst: event.Burst,
},
Member: *event.Member,
MessageAuthorID: event.MessageAuthorID,
Expand All @@ -59,6 +65,8 @@ func gatewayHandlerMessageReactionRemove(client bot.Client, sequenceNumber int,
GuildID: event.GuildID,
UserID: event.UserID,
Emoji: event.Emoji,
BurstColors: event.BurstColors,
Burst: event.Burst,
},
})

Expand All @@ -70,6 +78,8 @@ func gatewayHandlerMessageReactionRemove(client bot.Client, sequenceNumber int,
ChannelID: event.ChannelID,
UserID: event.UserID,
Emoji: event.Emoji,
BurstColors: event.BurstColors,
Burst: event.Burst,
},
})
} else {
Expand All @@ -81,6 +91,8 @@ func gatewayHandlerMessageReactionRemove(client bot.Client, sequenceNumber int,
GuildID: *event.GuildID,
UserID: event.UserID,
Emoji: event.Emoji,
BurstColors: event.BurstColors,
Burst: event.Burst,
},
})
}
Expand Down

0 comments on commit cdef17e

Please sign in to comment.