Fix reaction panel creation
This commit is contained in:
parent
3bfb958f15
commit
1540cbb682
@ -205,18 +205,23 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
|
|||||||
Label: panel.Title,
|
Label: panel.Title,
|
||||||
CustomId: panel.CustomId,
|
CustomId: panel.CustomId,
|
||||||
Style: component.ButtonStylePrimary,
|
Style: component.ButtonStylePrimary,
|
||||||
Emoji: emoji.Emoji{
|
Emoji: emoji.Emoji{
|
||||||
Name: panel.ReactionEmote,
|
Name: panel.ReactionEmote,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows []component.Component
|
var rows []component.Component
|
||||||
for i := 0; i < int(math.Ceil(float64(len(buttons) / 5))); i++ {
|
for i := 0; i <= int(math.Ceil(float64(len(buttons)/5))); i++ {
|
||||||
lb := i * 5
|
lb := i * 5
|
||||||
ub := lb + 5
|
ub := lb + 5
|
||||||
if ub > len(buttons) {
|
|
||||||
ub = len(buttons) - 1
|
if ub >= len(buttons) {
|
||||||
|
ub = len(buttons)
|
||||||
|
}
|
||||||
|
|
||||||
|
if lb >= ub {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
row := component.BuildActionRow(buttons[lb:ub]...)
|
row := component.BuildActionRow(buttons[lb:ub]...)
|
||||||
@ -225,9 +230,7 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
|
|||||||
|
|
||||||
data := rest.CreateMessageData{
|
data := rest.CreateMessageData{
|
||||||
Embed: e,
|
Embed: e,
|
||||||
Components: []component.Component{
|
Components: rows,
|
||||||
component.BuildActionRow(buttons...),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := rest.CreateMessage(ctx.Token, ctx.RateLimiter, d.ChannelId, data)
|
msg, err := rest.CreateMessage(ctx.Token, ctx.RateLimiter, d.ChannelId, data)
|
||||||
|
2
go.mod
2
go.mod
@ -21,7 +21,7 @@ require (
|
|||||||
github.com/jackc/pgx/v4 v4.7.1
|
github.com/jackc/pgx/v4 v4.7.1
|
||||||
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
|
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/rxdn/gdl v0.0.0-20210528152706-5da182da93db
|
github.com/rxdn/gdl v0.0.0-20210602135239-d993749b319d
|
||||||
github.com/sirupsen/logrus v1.5.0
|
github.com/sirupsen/logrus v1.5.0
|
||||||
github.com/ulule/limiter/v3 v3.5.0
|
github.com/ulule/limiter/v3 v3.5.0
|
||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user