@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
114 lines (111 loc) • 5.82 kB
TypeScript
import { WebClientOptions, ChatPostMessageResponse, RemindersAddResponse, ConversationsCreateResponse, ReactionsAddResponse, ConversationsInviteResponse, ConversationsKickResponse, FilesUploadResponse } from '@slack/web-api';
export * from '@slack/web-api';
import * as _slack_web_api_dist_types_response_FilesInfoResponse from '@slack/web-api/dist/types/response/FilesInfoResponse';
import * as _slack_web_api_dist_types_response_UsersInfoResponse from '@slack/web-api/dist/types/response/UsersInfoResponse';
import * as _slack_web_api_dist_types_response_UsersLookupByEmailResponse from '@slack/web-api/dist/types/response/UsersLookupByEmailResponse';
import * as _slack_web_api_dist_types_response_UsersListResponse from '@slack/web-api/dist/types/response/UsersListResponse';
import * as _slack_web_api_dist_types_response_ConversationsInfoResponse from '@slack/web-api/dist/types/response/ConversationsInfoResponse';
import * as _slack_web_api_dist_types_response_ConversationsListResponse from '@slack/web-api/dist/types/response/ConversationsListResponse';
import { Buffer } from 'buffer';
declare class MicrofoxSlackClient {
private web;
constructor(token: string, options?: WebClientOptions);
/**
* Lists all public and private channels in a workspace.
*/
listChannels(): Promise<_slack_web_api_dist_types_response_ConversationsListResponse.Channel[] | undefined>;
/**
* Fetches information about a conversation.
* @param channelId Conversation ID to fetch information for.
*/
getChannelConversationInfo(channelId: string): Promise<_slack_web_api_dist_types_response_ConversationsInfoResponse.Channel | undefined>;
/**
* Lists all users in a workspace.
*/
listUsers(): Promise<_slack_web_api_dist_types_response_UsersListResponse.Member[] | undefined>;
/**
* Lists all users in a channel.
* @param channelId Channel ID to get members of.
*/
listChannelUsers(channelId: string): Promise<string[] | undefined>;
/**
* Finds a user by their email address.
* @param email The email address of the user to find.
*/
searchUser(email: string): Promise<_slack_web_api_dist_types_response_UsersLookupByEmailResponse.User | undefined>;
/**
* Finds a channel by its name. This is case-insensitive.
* @param name The name of the channel to find.
*/
searchChannel(name: string): Promise<_slack_web_api_dist_types_response_ConversationsListResponse.Channel | undefined>;
/**
* Sends a direct message to a user.
* @param userId The ID of the user to message.
* @param text The text of the message to send.
*/
messageUser(userId: string, text: string): Promise<ChatPostMessageResponse>;
/**
* Sends a message to a channel.
* @param channelId The ID of the channel to message.
* @param text The text of the message to send.
*/
messageChannel(channelId: string, text: string): Promise<ChatPostMessageResponse>;
/**
* Sets a reminder for a user.
* @param userId The ID of the user to set a reminder for.
* @param text The text of the reminder.
* @param time A string describing when the reminder should fire (e.g., "in 5 minutes" or a Unix timestamp).
*/
setReminder(userId: string, text: string, time: string): Promise<RemindersAddResponse>;
/**
* Creates a new channel.
* @param name The name of the channel to create.
* @param isPrivate Whether the channel should be private. Defaults to false.
*/
createChannel(name: string, isPrivate?: boolean): Promise<ConversationsCreateResponse['channel']>;
/**
* Adds a reaction to a message.
* @param channelId The ID of the channel where the message is.
* @param timestamp The timestamp of the message to react to.
* @param reaction The name of the emoji to use for the reaction.
*/
reactMessage(channelId: string, timestamp: string, reaction: string): Promise<ReactionsAddResponse>;
/**
* Gets information about a user.
* @param userId The ID of the user to get information for.
*/
getUserInfo(userId: string): Promise<_slack_web_api_dist_types_response_UsersInfoResponse.User | undefined>;
/**
* Replies to a message in a thread.
* @param channelId The ID of the channel where the message is.
* @param thread_ts The timestamp of the message to reply to, establishing the thread.
* @param text The text of the reply.
*/
replyMessage(channelId: string, thread_ts: string, text: string): Promise<ChatPostMessageResponse>;
/**
* Adds a user to a channel.
* @param channelId The ID of the channel to add the user to.
* @param userId The ID of the user to add.
*/
addUserToChannel(channelId: string, userId: string): Promise<ConversationsInviteResponse>;
/**
* Removes a user from a channel.
* @param channelId The ID of the channel to remove the user from.
* @param userId The ID of the user to remove.
*/
removeUserFromChannel(channelId: string, userId: string): Promise<ConversationsKickResponse>;
/**
* Uploads a file to a channel.
* @param channelId The ID of the channel to upload the file to. Can be a comma-separated list of strings.
* @param file A Buffer containing the file content.
* @param filename The name of the file.
* @param title An optional title for the file.
*/
sendFile(channelId: string, file: Buffer, filename: string, title?: string): Promise<FilesUploadResponse>;
/**
* Gets information about a file.
* @param fileId The ID of the file to get information for.
*/
getFileInfo(fileId: string): Promise<_slack_web_api_dist_types_response_FilesInfoResponse.File | undefined>;
}
export { MicrofoxSlackClient };