fix: edit next, prev
This commit is contained in:
parent
7390cc31ed
commit
fb58599991
1 changed files with 24 additions and 36 deletions
|
@ -52,34 +52,32 @@ func (b *PaginationEmbedBuilder) Start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeComponents(id string, current, total int) []discordgo.MessageComponent {
|
func makeComponents(id string, current, total int) *discordgo.ActionsRow {
|
||||||
disabled := false
|
disabled := false
|
||||||
|
|
||||||
if total == 1 {
|
if total == 1 {
|
||||||
disabled = true
|
disabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return []discordgo.MessageComponent{
|
return &discordgo.ActionsRow{
|
||||||
discordgo.ActionsRow{
|
Components: []discordgo.MessageComponent{
|
||||||
Components: []discordgo.MessageComponent{
|
discordgo.Button{
|
||||||
discordgo.Button{
|
Style: discordgo.PrimaryButton,
|
||||||
Style: discordgo.PrimaryButton,
|
Label: "이전",
|
||||||
Label: "이전",
|
CustomID: MakePaginationEmbedPrev(id),
|
||||||
CustomID: MakePaginationEmbedPrev(id),
|
Disabled: disabled,
|
||||||
Disabled: disabled,
|
},
|
||||||
},
|
discordgo.Button{
|
||||||
discordgo.Button{
|
Style: discordgo.SecondaryButton,
|
||||||
Style: discordgo.SecondaryButton,
|
Label: fmt.Sprintf("(%d/%d)", current, total),
|
||||||
Label: fmt.Sprintf("(%d/%d)", current, total),
|
CustomID: MakePaginationEmbedPages(id),
|
||||||
CustomID: MakePaginationEmbedPages(id),
|
Disabled: disabled,
|
||||||
Disabled: disabled,
|
},
|
||||||
},
|
discordgo.Button{
|
||||||
discordgo.Button{
|
Style: discordgo.PrimaryButton,
|
||||||
Style: discordgo.PrimaryButton,
|
Label: "다음",
|
||||||
Label: "다음",
|
CustomID: MakePaginationEmbedNext(id),
|
||||||
CustomID: MakePaginationEmbedNext(id),
|
Disabled: disabled,
|
||||||
Disabled: disabled,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -116,7 +114,7 @@ func startPaginationEmbed(m any, userId string, e *discordgo.MessageEmbed, data
|
||||||
|
|
||||||
NewMessageSender(m).
|
NewMessageSender(m).
|
||||||
AddEmbeds(e).
|
AddEmbeds(e).
|
||||||
AddComponents(makeComponents(id, p.Current, p.Total)...).
|
AddComponents(makeComponents(id, p.Current, p.Total)).
|
||||||
SetReply(true).
|
SetReply(true).
|
||||||
SetEphemeral(true).
|
SetEphemeral(true).
|
||||||
Send()
|
Send()
|
||||||
|
@ -148,12 +146,7 @@ func (p *PaginationEmbed) Prev(i *InteractionCreate) {
|
||||||
|
|
||||||
p.Current -= 1
|
p.Current -= 1
|
||||||
|
|
||||||
p.Embed.Description = makeDesc(p.desc, p.Data[p.Current-1])
|
p.Set(i, p.Current)
|
||||||
|
|
||||||
i.Update(&discordgo.InteractionResponseData{
|
|
||||||
Embeds: []*discordgo.MessageEmbed{p.Embed},
|
|
||||||
Components: makeComponents(p.id, p.Current, p.Total),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PaginationEmbed) Next(i *InteractionCreate) {
|
func (p *PaginationEmbed) Next(i *InteractionCreate) {
|
||||||
|
@ -173,12 +166,7 @@ func (p *PaginationEmbed) Next(i *InteractionCreate) {
|
||||||
|
|
||||||
p.Current += 1
|
p.Current += 1
|
||||||
|
|
||||||
p.Embed.Description = makeDesc(p.desc, p.Data[p.Current-1])
|
p.Set(i, p.Current)
|
||||||
|
|
||||||
i.Update(&discordgo.InteractionResponseData{
|
|
||||||
Embeds: []*discordgo.MessageEmbed{p.Embed},
|
|
||||||
Components: makeComponents(p.id, p.Current, p.Total),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PaginationEmbed) Set(i *InteractionCreate, page int) {
|
func (p *PaginationEmbed) Set(i *InteractionCreate, page int) {
|
||||||
|
@ -216,7 +204,7 @@ func (p *PaginationEmbed) Set(i *InteractionCreate, page int) {
|
||||||
|
|
||||||
i.Update(&discordgo.InteractionResponseData{
|
i.Update(&discordgo.InteractionResponseData{
|
||||||
Embeds: []*discordgo.MessageEmbed{p.Embed},
|
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