diff --git a/app/http/endpoints/api/panel/multipanelcreate.go b/app/http/endpoints/api/panel/multipanelcreate.go index 4f02343..c324ea7 100644 --- a/app/http/endpoints/api/panel/multipanelcreate.go +++ b/app/http/endpoints/api/panel/multipanelcreate.go @@ -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) diff --git a/go.mod b/go.mod index 20f01cc..cb23e8b 100644 --- a/go.mod +++ b/go.mod @@ -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