chenhg5/cc-connect · error

discord: no buttons provided

Error message

discord: no buttons provided

What it means

SendWithButtons rejects the call up front when the buttons slice is empty, because Discord component messages require at least one ActionsRow/Button. The library treats an empty button payload as an invalid request rather than sending a button-less message. It fires before any Discord API call is made.

Source

Thrown at platform/discord/discord.go:1180

			case 1:
				style = discordgo.DangerButton
			case 2:
				style = discordgo.PrimaryButton
			}
			buttons = append(buttons, discordgo.Button{
				Label:    btn.Text,
				Style:    style,
				CustomID: btn.Data,
			})
		}
		components = append(components, discordgo.ActionsRow{Components: buttons})
	}
	return components
}

func (p *Platform) SendWithButtons(ctx context.Context, rctx any, content string, buttons [][]core.ButtonOption) error {
	if len(buttons) == 0 {
		return fmt.Errorf("discord: no buttons provided")
	}
	components := buildDiscordActionRows(buttons)
	if len(components) == 0 {
		return fmt.Errorf("discord: no buttons provided")
	}

	switch rc := rctx.(type) {
	case *interactionReplyCtx:
		if err := p.sendInteraction(rc, content); err != nil {
			return err
		}
		_, err := p.session.FollowupMessageCreate(rc.interaction, true, &discordgo.WebhookParams{
			Content:    content,
			Components: components,
		})
		if err != nil {
			return fmt.Errorf("discord: send button followup: %w", err)
		}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Ensure callers pass at least one non-empty button row before calling SendWithButtons
  2. Fall back to a plain Reply/Send when no buttons are needed instead of calling SendWithButtons
  3. Validate the button grid in the caller and skip/return early
  4. Log the call site to find where the empty grid originates

Example fix

// before
p.SendWithButtons(ctx, rctx, content, nil)
// after
if len(buttons) == 0 {
    return p.Reply(ctx, rctx, content)
}
return p.SendWithButtons(ctx, rctx, content, buttons)
Defensive patterns

Strategy: validation

Validate before calling

if len(buttons) == 0 || len(buttons[0]) == 0 {
    return errors.New("at least one button row with a button is required")
}

Try / catch

if err := p.SendWithButtons(ctx, rctx, content, buttons); err != nil {
    if strings.Contains(err.Error(), "no buttons provided") {
        return p.Reply(ctx, rctx, content)
    }
    return err
}

Prevention

When it happens

Trigger: Platform.SendWithButtons called with buttons == nil or buttons == [][]core.ButtonOption{} — typically a caller built the button grid conditionally and all conditions were false.

Common situations: Dynamic button construction that ends up empty; config produced no quick-action buttons; a caller passed an empty default value.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/6b3b7b59027ab046. Report an issue: GitHub.