diff --git a/app/http/endpoints/api/panel/multipanelcreate.go b/app/http/endpoints/api/panel/multipanelcreate.go index 5304391..cbbb6f4 100644 --- a/app/http/endpoints/api/panel/multipanelcreate.go +++ b/app/http/endpoints/api/panel/multipanelcreate.go @@ -16,16 +16,15 @@ import ( "github.com/rxdn/gdl/objects/channel/message" "github.com/rxdn/gdl/rest" "github.com/rxdn/gdl/rest/request" - gdlutils "github.com/rxdn/gdl/utils" "golang.org/x/sync/errgroup" ) type multiPanelCreateData struct { - Title string `json:"title"` - Content string `json:"content"` - Colour int32 `json:"colour"` - ChannelId uint64 `json:"channel_id,string"` - Panels gdlutils.Uint64StringSlice `json:"panels"` + Title string `json:"title"` + Content string `json:"content"` + Colour int32 `json:"colour"` + ChannelId uint64 `json:"channel_id,string"` + Panels []int `json:"panels"` } func MultiPanelCreate(ctx *gin.Context) { @@ -71,7 +70,7 @@ func MultiPanelCreate(ctx *gin.Context) { if err := data.addReactions(&botContext, data.ChannelId, messageId, panels); err != nil { var unwrapped request.RestError - if errors.As(err, &unwrapped); unwrapped.StatusCode == 403{ + if errors.As(err, &unwrapped); unwrapped.StatusCode == 403 { ctx.JSON(500, utils.ErrorJson(errors.New("I do not have permission to add reactions in the provided channel"))) } else { ctx.JSON(500, utils.ErrorJson(err)) @@ -111,7 +110,7 @@ func MultiPanelCreate(ctx *gin.Context) { ctx.JSON(200, gin.H{ "success": true, - "data": multiPanel, + "data": multiPanel, }) } @@ -184,7 +183,7 @@ func (d *multiPanelCreateData) validatePanels(guildId uint64) (panels []database var valid bool // find panel struct for _, panel := range existingPanels { - if panel.MessageId == panelId { + if panel.PanelId == panelId { // check there isn't a panel with the same reaction emote for _, previous := range panels { if previous.ReactionEmote == panel.ReactionEmote { @@ -226,7 +225,6 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b return } - func (d *multiPanelCreateData) addReactions(ctx *botcontext.BotContext, channelId, messageId uint64, panels []database.Panel) (err error) { for _, panel := range panels { if err = rest.CreateReaction(ctx.Token, ctx.RateLimiter, channelId, messageId, panel.ReactionEmote); err != nil { @@ -235,4 +233,4 @@ func (d *multiPanelCreateData) addReactions(ctx *botcontext.BotContext, channelI } return -} \ No newline at end of file +} diff --git a/public/templates/includes/multipaneleditmodal.tmpl b/public/templates/includes/multipaneleditmodal.tmpl index d2c8c8e..88a4124 100644 --- a/public/templates/includes/multipaneleditmodal.tmpl +++ b/public/templates/includes/multipaneleditmodal.tmpl @@ -125,7 +125,7 @@ 'content': getValue('multi-edit-content'), 'colour': parseInt(`0x${getValue('multi-edit-colour').slice(1)}`), 'channel_id': channelContainer.options[channelContainer.selectedIndex].value, - 'panels': $('#multi-edit-panels').val() + 'panels': $('#multi-edit-panels').val().map((id) => parseInt(id)) }; $('#multieditmodal').modal('hide'); diff --git a/public/templates/views/panels.tmpl b/public/templates/views/panels.tmpl index ebda468..a586bd6 100644 --- a/public/templates/views/panels.tmpl +++ b/public/templates/views/panels.tmpl @@ -317,7 +317,7 @@ 'content': getValue('multi-content'), 'colour': parseInt(`0x${getValue('multi-colour').slice(1)}`), 'channel_id': channelContainer.options[channelContainer.selectedIndex].value, - 'panels': $('#multi-panels').val() + 'panels': $('#multi-panels').val().map((id) => parseInt(id)) }; const res = await axios.post('/api/{{.guildId}}/multipanels', data);