makeSlackbotRequest (slackbot/client.ts)

corsair · packages/slackbot/client.ts · typescript · Apache-2.0
integration

Makes requests to Slack API with error handling.

// Source: https://github.com/corsairdev/corsair | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import type {
	ApiRequestOptions,
	OpenAPIConfig,
	RateLimitConfig,
} from 'corsair/http';
import { request } from 'corsair/http';

/**
 * Slack returns HTTP 200 with `{ ok: false, error: "<code>" }` for most
 * application-level failures, so the machine-readable `error` code is carried
 * separately from the human-readable message.
 */
export class SlackbotAPIError extends Error {
	constructor(
		message: string,
		public readonly code?: string,
	) {
		super(message);
		this.name = 'SlackbotAPIError';
	}
}

const SLACKBOT_API_BASE = 'https://slack.com/api';

/**
 * Slack enforces tier

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key