Fix reaction panel creation

This commit is contained in:
rxdn 2021-06-02 15:24:11 +01:00
parent 3bfb958f15
commit 1540cbb682
2 changed files with 11 additions and 8 deletions

View File

@ -205,18 +205,23 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
Label: panel.Title,
CustomId: panel.CustomId,
Style: component.ButtonStylePrimary,
Emoji: emoji.Emoji{
Emoji: emoji.Emoji{
Name: panel.ReactionEmote,
},
})
}
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
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]...)
@ -225,9 +230,7 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
data := rest.CreateMessageData{
Embed: e,
Components: []component.Component{
component.BuildActionRow(buttons...),
},
Components: rows,
}
msg, err := rest.CreateMessage(ctx.Token, ctx.RateLimiter, d.ChannelId, data)

2
go.mod
View File

@ -21,7 +21,7 @@ require (
github.com/jackc/pgx/v4 v4.7.1
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
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/ulule/limiter/v3 v3.5.0
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a