Skip to content

Commit

Permalink
Fix type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
zuuring committed Nov 4, 2024
1 parent 0dce2bd commit 83a05e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
14 changes: 5 additions & 9 deletions discord-scripts/thread-management/check-thread-archiving.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
} from "../../lib/discord/utils.ts"
import {
getAllThreadMetadata,
isInPermittedCategoryOrChannel,
getThreadMetadata,
updateThreadMetadata,
} from "../../lib/discord/channel-metadata.ts"
Expand All @@ -51,14 +50,14 @@ function requestFollowUpAction(
followUpRequester: GuildMember | APIInteractionGuildMember | null,
requestedAction: string,
followUpUserId: string,
robot: any
robot?: Robot,
) {
const requestingUserId = followUpRequester?.user.id

if (followUpUserId === requestingUserId) {
// If the user designates themselves, delete the initial bot message to remove the dropdown
interaction.deleteReply().catch((error) => {
robot.logger.info("Failed to delete dropdown message:", error)
robot?.logger.info("Failed to delete dropdown message:", error)
})

interaction
Expand All @@ -69,7 +68,7 @@ function requestFollowUpAction(
ephemeral: true,
})
.catch((error) => {
robot.logger.info("Failed to send ephemeral follow-up message:", error)
robot?.logger.info("Failed to send ephemeral follow-up message:", error)
})
} else {
// If another user is designated, send a message in the thread tagging them
Expand All @@ -80,11 +79,11 @@ function requestFollowUpAction(
)} please ${requestedAction} this thread or it will be archived in 24 hours ❤️`,
})
.catch((error) => {
robot.logger.info("Failed to send message in thread:", error)
robot?.logger.info("Failed to send message in thread:", error)
})

interaction.deleteReply().catch((error) => {
robot.logger.info("Failed to delete initial bot message:", error)
robot?.logger.info("Failed to delete initial bot message:", error)
})
}
}
Expand Down Expand Up @@ -148,7 +147,6 @@ const threadActions: {
interaction.member,
"capture the task(s) associated with",
userIdToTag,
Robot
)
},
},
Expand Down Expand Up @@ -194,7 +192,6 @@ const threadActions: {
interaction.member,
"capture the task(s) associated with",
userIdToTag,
Robot
)
},
},
Expand Down Expand Up @@ -240,7 +237,6 @@ const threadActions: {
interaction.member,
"capture the task(s) associated with",
userIdToTag,
Robot
)
},
},
Expand Down
3 changes: 2 additions & 1 deletion lib/discord/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { DiscordBot } from "hubot-discord"
const BASE_ROLE_ID = "1158333090494689290"

// Channels that are used for testing, may be treated differently.
const TESTING_CHANNEL_NAMES = process.env.TESTING_CHANNEL_NAMES?.split(",") ?? []
const TESTING_CHANNEL_NAMES =
process.env.TESTING_CHANNEL_NAMES?.split(",") ?? []

/**
* Hubot Robot type with Discord adapter.
Expand Down

0 comments on commit 83a05e7

Please sign in to comment.