-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor logging for Slack API calls
- Loading branch information
1 parent
fef8000
commit d9dd6d2
Showing
3 changed files
with
38 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
import { Middleware, SlackCommandMiddlewareArgs } from "@slack/bolt"; | ||
import { AllMiddlewareArgs, SlackCommandMiddlewareArgs } from "@slack/bolt"; | ||
import { logCommandUsed } from "../../utils/logging"; | ||
import { postEphemeralMessage } from "../../utils/slack"; | ||
import { SlackLogger } from "../../classes/SlackLogger"; | ||
|
||
const message = `For more information, check out <https://github.com/waterloo-rocketry/minerva-rewrite/blob/main/README.md|minerva's README>.`; | ||
|
||
export const helpCommandHandler: Middleware<SlackCommandMiddlewareArgs> = async ({ command, ack, client }) => { | ||
await ack(); | ||
await logCommandUsed(command); | ||
export async function helpCommandHandler({ | ||
command, | ||
ack, | ||
client, | ||
}: SlackCommandMiddlewareArgs & AllMiddlewareArgs): Promise<void> { | ||
ack(); | ||
logCommandUsed(command); | ||
|
||
await postEphemeralMessage(client, command.channel_id, command.user_id, message); | ||
}; | ||
try { | ||
await postEphemeralMessage(client, command.channel_id, command.user_id, message); | ||
} catch (error) { | ||
SlackLogger.getInstance().error("Failed to send help message", error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters