@microfox/slack
Version:
This package provides a lightweight, proxy interface to the official Slack Web API, offering a curated set of the most commonly used functions for building Slack integrations. It is designed to be simple, efficient, and easy to integrate into your project
47 lines (33 loc) • 1.3 kB
Markdown
The `MicrofoxSlackClient` is a custom client designed to simplify common automation tasks by providing a set of minimal, easy-to-use functions that wrap the official `@slack/web-api`.
To create a new `MicrofoxSlackClient` instance, you need to provide a Slack API token.
```typescript
import { MicrofoxSlackClient } from '@microfox/slack';
// You can get this token from your Slack app settings
const token = process.env.SLACK_BOT_TOKEN;
const client = new MicrofoxSlackClient(token);
```
You can also provide a `WebClientOptions` object to configure the underlying `WebClient` with more advanced settings, such as custom retry logic, TLS configuration, or logging.
```typescript
import { MicrofoxSlackClient } from '@microfox/slack';
import { LogLevel } from '@slack/web-api';
const token = process.env.SLACK_BOT_TOKEN;
const client = new MicrofoxSlackClient(token, {
logLevel: LogLevel.DEBUG
});
```
Once you have a `MicrofoxSlackClient` instance, you can use it to call any of its custom methods.
```typescript
(async () => {
try {
// Example: List all channels
const channels = await client.listChannels();
console.log(channels);
} catch (error) {
console.error(error);
}
})();
```