Skip to content

Commit

Permalink
fix: handle missing doc queries (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jun 1, 2023
1 parent 9911b3e commit 908d47f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/DocsLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ const make = Effect.gen(function* (_) {
),
docs: allDocs,
}),
Effect.bind("embed", ({ key, docs }) => docs.map[key].embed),
Effect.bind("entry", ({ key, docs }) =>
Option.fromNullable(docs.map[key]),
),
Effect.bind("embed", ({ entry }) => entry.embed),
Effect.map(({ embed, reveal }) =>
Ix.response({
type: Discord.InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE,
Expand All @@ -116,6 +119,19 @@ const make = Effect.gen(function* (_) {
},
}),
),
Effect.catchTags({
NoSuchElementException: () =>
Effect.succeed(
Ix.response({
type: Discord.InteractionCallbackType
.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
flags: Discord.MessageFlag.EPHEMERAL,
content: `Sorry, that query could not found.`,
},
}),
),
}),
),
)

Expand Down

0 comments on commit 908d47f

Please sign in to comment.