fixed single role calls

This commit is contained in:
2025-04-08 12:10:48 -04:00
parent 14e5187535
commit 34a9c5b65b
+15 -13
View File
@@ -289,7 +289,6 @@ func HandleReactionRoleModalSubmit(s *discordgo.Session, i *discordgo.Interactio
data := i.ModalSubmitData()
// There will be two action rows per pair.
count := len(data.Components) / 2
var buttons []discordgo.MessageComponent
// Retrieve guild roles to verify existence.
@@ -311,17 +310,23 @@ func HandleReactionRoleModalSubmit(s *discordgo.Session, i *discordgo.Interactio
// FLAT
var rolearr [][]string
for idx := range count {
for _, comp := range data.Components {
row, ok := comp.(*discordgo.ActionsRow)
for _, comp := range data.Components {
row, ok := comp.(*discordgo.ActionsRow)
if !ok {
continue
}
for _, innerComp := range row.Components {
textInput, ok := innerComp.(*discordgo.TextInput)
if !ok {
continue
}
inp := row.Components[idx].(*discordgo.TextInput)
rolearr = append(rolearr, []string{inp.Value, strings.Split(inp.CustomID, "_")[1]})
parts := strings.Split(textInput.CustomID, "_")
if len(parts) < 2 {
continue
}
roleID := parts[1]
rolearr = append(rolearr, []string{textInput.Value, roleID})
}
}
@@ -381,10 +386,7 @@ func HandleReactionRoleModalSubmit(s *discordgo.Session, i *discordgo.Interactio
// Arrange buttons into rows (up to 5 per row).
var components []discordgo.MessageComponent
for j := 0; j < len(buttons); j += 5 {
end := j + 5
if end > len(buttons) {
end = len(buttons)
}
end := min(j+5, len(buttons))
row := discordgo.ActionsRow{
Components: buttons[j:end],
}