Fix multipanel creation
This commit is contained in:
parent
faf55caef6
commit
ffe7dbb1f9
@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/rxdn/gdl/objects/channel/message"
|
"github.com/rxdn/gdl/objects/channel/message"
|
||||||
"github.com/rxdn/gdl/rest"
|
"github.com/rxdn/gdl/rest"
|
||||||
"github.com/rxdn/gdl/rest/request"
|
"github.com/rxdn/gdl/rest/request"
|
||||||
gdlutils "github.com/rxdn/gdl/utils"
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ type multiPanelCreateData struct {
|
|||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Colour int32 `json:"colour"`
|
Colour int32 `json:"colour"`
|
||||||
ChannelId uint64 `json:"channel_id,string"`
|
ChannelId uint64 `json:"channel_id,string"`
|
||||||
Panels gdlutils.Uint64StringSlice `json:"panels"`
|
Panels []int `json:"panels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func MultiPanelCreate(ctx *gin.Context) {
|
func MultiPanelCreate(ctx *gin.Context) {
|
||||||
@ -184,7 +183,7 @@ func (d *multiPanelCreateData) validatePanels(guildId uint64) (panels []database
|
|||||||
var valid bool
|
var valid bool
|
||||||
// find panel struct
|
// find panel struct
|
||||||
for _, panel := range existingPanels {
|
for _, panel := range existingPanels {
|
||||||
if panel.MessageId == panelId {
|
if panel.PanelId == panelId {
|
||||||
// check there isn't a panel with the same reaction emote
|
// check there isn't a panel with the same reaction emote
|
||||||
for _, previous := range panels {
|
for _, previous := range panels {
|
||||||
if previous.ReactionEmote == panel.ReactionEmote {
|
if previous.ReactionEmote == panel.ReactionEmote {
|
||||||
@ -226,7 +225,6 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (d *multiPanelCreateData) addReactions(ctx *botcontext.BotContext, channelId, messageId uint64, panels []database.Panel) (err error) {
|
func (d *multiPanelCreateData) addReactions(ctx *botcontext.BotContext, channelId, messageId uint64, panels []database.Panel) (err error) {
|
||||||
for _, panel := range panels {
|
for _, panel := range panels {
|
||||||
if err = rest.CreateReaction(ctx.Token, ctx.RateLimiter, channelId, messageId, panel.ReactionEmote); err != nil {
|
if err = rest.CreateReaction(ctx.Token, ctx.RateLimiter, channelId, messageId, panel.ReactionEmote); err != nil {
|
||||||
|
@ -125,7 +125,7 @@
|
|||||||
'content': getValue('multi-edit-content'),
|
'content': getValue('multi-edit-content'),
|
||||||
'colour': parseInt(`0x${getValue('multi-edit-colour').slice(1)}`),
|
'colour': parseInt(`0x${getValue('multi-edit-colour').slice(1)}`),
|
||||||
'channel_id': channelContainer.options[channelContainer.selectedIndex].value,
|
'channel_id': channelContainer.options[channelContainer.selectedIndex].value,
|
||||||
'panels': $('#multi-edit-panels').val()
|
'panels': $('#multi-edit-panels').val().map((id) => parseInt(id))
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#multieditmodal').modal('hide');
|
$('#multieditmodal').modal('hide');
|
||||||
|
@ -317,7 +317,7 @@
|
|||||||
'content': getValue('multi-content'),
|
'content': getValue('multi-content'),
|
||||||
'colour': parseInt(`0x${getValue('multi-colour').slice(1)}`),
|
'colour': parseInt(`0x${getValue('multi-colour').slice(1)}`),
|
||||||
'channel_id': channelContainer.options[channelContainer.selectedIndex].value,
|
'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);
|
const res = await axios.post('/api/{{.guildId}}/multipanels', data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user