Compare commits

...

3 Commits

Author SHA1 Message Date
bitspill db8fdfc95f
Merge 0e24fffde0 into 2703326028 2024-02-21 03:49:35 -07:00
diamondburned 2703326028
state: Fix reaction.Me on MessageReactionAddEvent 2024-02-14 03:26:30 -08:00
bitspill 0e24fffde0
fix IntegerOptionType Unmarshall 2023-02-01 05:25:39 -06:00
2 changed files with 19 additions and 20 deletions

View File

@ -540,16 +540,16 @@ var optionSupportedSnowflakeTypes = map[reflect.Type]CommandOptionType{
}
var optionKindMap = map[reflect.Kind]CommandOptionType{
reflect.Int: NumberOptionType,
reflect.Int8: NumberOptionType,
reflect.Int16: NumberOptionType,
reflect.Int32: NumberOptionType,
reflect.Int64: NumberOptionType,
reflect.Uint: NumberOptionType,
reflect.Uint8: NumberOptionType,
reflect.Uint16: NumberOptionType,
reflect.Uint32: NumberOptionType,
reflect.Uint64: NumberOptionType,
reflect.Int: IntegerOptionType,
reflect.Int8: IntegerOptionType,
reflect.Int16: IntegerOptionType,
reflect.Int32: IntegerOptionType,
reflect.Int64: IntegerOptionType,
reflect.Uint: IntegerOptionType,
reflect.Uint8: IntegerOptionType,
reflect.Uint16: IntegerOptionType,
reflect.Uint32: IntegerOptionType,
reflect.Uint64: IntegerOptionType,
reflect.Float32: NumberOptionType,
reflect.Float64: NumberOptionType,
reflect.String: StringOptionType,

View File

@ -261,16 +261,18 @@ func (s *State) onEvent(iface interface{}) {
}
case *gateway.MessageReactionAddEvent:
var me bool
if u, _ := s.Cabinet.Me(); u != nil {
me = ev.UserID == u.ID
}
s.editMessage(ev.ChannelID, ev.MessageID, func(m *discord.Message) bool {
if i := findReaction(m.Reactions, ev.Emoji); i > -1 {
// Copy the reactions slice so it's not racy.
m.Reactions = append([]discord.Reaction(nil), m.Reactions...)
m.Reactions[i].Count++
m.Reactions[i].Me = m.Reactions[i].Me || me
} else {
var me bool
if u, _ := s.Cabinet.Me(); u != nil {
me = ev.UserID == u.ID
}
old := m.Reactions
m.Reactions = make([]discord.Reaction, 0, len(old)+1)
m.Reactions = append(m.Reactions, old...)
@ -291,16 +293,13 @@ func (s *State) onEvent(iface interface{}) {
}
r := &m.Reactions[i]
newCount := r.Count - 1
switch {
case newCount < 1: // If the count is 0:
// If the count is 0:
if (r.Count - 1) < 1 {
old := m.Reactions
m.Reactions = make([]discord.Reaction, len(m.Reactions)-1)
copy(m.Reactions[0:], old[:i])
copy(m.Reactions[i:], old[i+1:])
default:
} else {
r.Count--
if r.Me { // If reaction removal is the user's
u, err := s.Cabinet.Me()