-
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.
Add code block parameter for logging
- Loading branch information
1 parent
8915a89
commit b0be0f2
Showing
6 changed files
with
131 additions
and
70 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,17 +1,22 @@ | ||
import { slackBotToken } from "../../utils/env"; | ||
import { Middleware, 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); | ||
|
||
await client.chat.postEphemeral({ | ||
token: slackBotToken, | ||
channel: command.channel_id, | ||
user: command.user_id, | ||
text: message, | ||
}); | ||
try { | ||
await postEphemeralMessage(client, command.channel_id, command.user_id, message); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
throw new Error("This is a test error"); | ||
} catch (error) { | ||
SlackLogger.getInstance().error( | ||
`Failed to post ephemeral message to user \`${command.user_id}\` with error:`, | ||
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
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
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