Skip to content

Commit

Permalink
Add logger.debug to embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
zuuring committed Nov 29, 2024
1 parent 3e69d25 commit 7823e98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,7 @@ can then run hubot with the adapter.
Where `<adapter>` is the name of your adapter without the `hubot-` prefix.

[hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md

## Debugging

If you'd like to test certain aspects of Valkyrie with a debugger, use `robot.logger.debug` and in your environment variables the flag `export HUBOT_LOG_LEVEL="debug"` which will enable those messages to appear in terminal output.
7 changes: 6 additions & 1 deletion discord-scripts/fix-twitter-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ async function workingTwitterEmbeds(
export default function fixTwitterEmbeds(discordClient: Client, robot: Robot) {
// Process only messages that match the Twitter URL pattern
discordClient.on("messageCreate", (message) => {
robot.logger.debug(
`fixTwitterEmbeds: processing new message ${message.content}`,
)
if (message.content?.match(twitterUrlRegExp)) {
robot.logger.info(
`fixTwitterEmbeds: processing new message ${message.content}`,
)

workingTwitterEmbeds(message, robot.logger).catch((err) => {
robot.logger.error(
`fixTwitterEmbeds: failed to process new message ${message.content}: ${err}`,
Expand All @@ -83,6 +85,9 @@ export default function fixTwitterEmbeds(discordClient: Client, robot: Robot) {
})

discordClient.on("messageUpdate", (oldMessage, newMessage) => {
robot.logger.debug(
`fixTwitterEmbeds: processing updated message ${newMessage.content}`,
)
if (
newMessage.content?.match(twitterUrlRegExp) ||
oldMessage?.content?.match(twitterUrlRegExp)
Expand Down

0 comments on commit 7823e98

Please sign in to comment.