fix: edit next, prev
This commit is contained in:
parent
7390cc31ed
commit
fb58599991
1 changed files with 24 additions and 36 deletions
|
@ -52,15 +52,14 @@ func (b *PaginationEmbedBuilder) Start() {
|
|||
}
|
||||
}
|
||||
|
||||
func makeComponents(id string, current, total int) []discordgo.MessageComponent {
|
||||
func makeComponents(id string, current, total int) *discordgo.ActionsRow {
|
||||
disabled := false
|
||||
|
||||
if total == 1 {
|
||||
disabled = true
|
||||
}
|
||||
|
||||
return []discordgo.MessageComponent{
|
||||
discordgo.ActionsRow{
|
||||
return &discordgo.ActionsRow{
|
||||
Components: []discordgo.MessageComponent{
|
||||
discordgo.Button{
|
||||
Style: discordgo.PrimaryButton,
|
||||
|
@ -81,7 +80,6 @@ func makeComponents(id string, current, total int) []discordgo.MessageComponent
|
|||
Disabled: disabled,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +114,7 @@ func startPaginationEmbed(m any, userId string, e *discordgo.MessageEmbed, data
|
|||
|
||||
NewMessageSender(m).
|
||||
AddEmbeds(e).
|
||||
AddComponents(makeComponents(id, p.Current, p.Total)...).
|
||||
AddComponents(makeComponents(id, p.Current, p.Total)).
|
||||
SetReply(true).
|
||||
SetEphemeral(true).
|
||||
Send()
|
||||
|
@ -148,12 +146,7 @@ func (p *PaginationEmbed) Prev(i *InteractionCreate) {
|
|||
|
||||
p.Current -= 1
|
||||
|
||||
p.Embed.Description = makeDesc(p.desc, p.Data[p.Current-1])
|
||||
|
||||
i.Update(&discordgo.InteractionResponseData{
|
||||
Embeds: []*discordgo.MessageEmbed{p.Embed},
|
||||
Components: makeComponents(p.id, p.Current, p.Total),
|
||||
})
|
||||
p.Set(i, p.Current)
|
||||
}
|
||||
|
||||
func (p *PaginationEmbed) Next(i *InteractionCreate) {
|
||||
|
@ -173,12 +166,7 @@ func (p *PaginationEmbed) Next(i *InteractionCreate) {
|
|||
|
||||
p.Current += 1
|
||||
|
||||
p.Embed.Description = makeDesc(p.desc, p.Data[p.Current-1])
|
||||
|
||||
i.Update(&discordgo.InteractionResponseData{
|
||||
Embeds: []*discordgo.MessageEmbed{p.Embed},
|
||||
Components: makeComponents(p.id, p.Current, p.Total),
|
||||
})
|
||||
p.Set(i, p.Current)
|
||||
}
|
||||
|
||||
func (p *PaginationEmbed) Set(i *InteractionCreate, page int) {
|
||||
|
@ -216,7 +204,7 @@ func (p *PaginationEmbed) Set(i *InteractionCreate, page int) {
|
|||
|
||||
i.Update(&discordgo.InteractionResponseData{
|
||||
Embeds: []*discordgo.MessageEmbed{p.Embed},
|
||||
Components: makeComponents(p.id, p.Current, p.Total),
|
||||
Components: []discordgo.MessageComponent{makeComponents(p.id, p.Current, p.Total)},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue