Skip to content

Commit

Permalink
fix(starboard): move type checking logic inside conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed May 23, 2023
1 parent dcbadcb commit 3a8a6e4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/features/starboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@ const updateStarboard = async (message: Message) => {

let existingMessageId = await get(['starboard', message.id, 'message']);

if (typeof existingMessageId !== 'string') {
throw new Error(`Message ID found for ${message.id} is not a string!`);
}

existingMessageId = existingMessageId.slice(1);

if (existingMessageId) {
if (typeof existingMessageId !== 'string') {
throw new Error(`Message ID found for ${message.id} is not a string!`);
}
existingMessageId = existingMessageId.slice(1);

const existingResolvedMessage = await starboard.messages
.fetch({ around: existingMessageId, limit: 3 })
.then((res) => res.find((k) => k.id === existingMessageId));
Expand Down

0 comments on commit 3a8a6e4

Please sign in to comment.