Skip to content

Commit

Permalink
Improve bot-related property types in context object
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Mar 16, 2024
1 parent 2785568 commit 2ee62f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export interface PreAuthorizeSlackAppContext {
actorEnterpriseId?: string;
actorTeamId?: string;
actorUserId?: string;
botId?: string;
botUserId?: string;
botId?: string; // this will always exist when initializing SlackAppContext
botUserId?: string; // this will always exist when initializing SlackAppContext
responseUrl?: string;
channelId?: string;
triggerId?: string;
Expand All @@ -32,6 +32,8 @@ export type Respond = (params: WebhookParams) => Promise<Response>;
export type SlackAppContext = {
client: SlackAPIClient;
botToken: string;
botId: string; // this must exist here
botUserId: string; // this must exist here
userToken?: string;
authorizeResult: AuthorizeResult;
} & PreAuthorizeSlackAppContext;
Expand Down
6 changes: 4 additions & 2 deletions src_deno/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export interface PreAuthorizeSlackAppContext {
actorEnterpriseId?: string;
actorTeamId?: string;
actorUserId?: string;
botId?: string;
botUserId?: string;
botId?: string; // this will always exist when initializing SlackAppContext
botUserId?: string; // this will always exist when initializing SlackAppContext
responseUrl?: string;
channelId?: string;
triggerId?: string;
Expand All @@ -32,6 +32,8 @@ export type Respond = (params: WebhookParams) => Promise<Response>;
export type SlackAppContext = {
client: SlackAPIClient;
botToken: string;
botId: string; // this must exist here
botUserId: string; // this must exist here
userToken?: string;
authorizeResult: AuthorizeResult;
} & PreAuthorizeSlackAppContext;
Expand Down
3 changes: 3 additions & 0 deletions test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ describe("SlackApp", () => {
// Events API
const appMentionEvent: EventLazyHandler<"app_mention"> = async ({
payload,
context,
}) => {
const type: "app_mention" = payload.type;
const botUserId: string = context.botUserId;
const botId: string = context.botId;
};
app.event("app_mention", appMentionEvent);

Expand Down

0 comments on commit 2ee62f0

Please sign in to comment.