Skip to content

Commit

Permalink
feat: silent option for /docs (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored May 27, 2023
1 parent bc0df3e commit dbd7e4b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/DocsLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Effect,
Http,
Layer,
Option,
Schedule,
Schema,
SchemaClass,
Expand Down Expand Up @@ -88,19 +89,30 @@ const make = Effect.gen(function* (_) {
required: true,
autocomplete: true,
},
{
type: Discord.ApplicationCommandOptionType.BOOLEAN,
name: "silent",
description: "Only show the results to you",
required: false,
},
],
},
ix =>
pipe(
Effect.all({
key: ix.optionValue("query"),
silent: Effect.map(
ix.optionValueOptional("silent"),
Option.getOrElse(() => false),
),
docs: allDocs,
}),
Effect.bind("embed", ({ key, docs }) => docs[1][key].embed),
Effect.map(({ embed }) =>
Effect.map(({ embed, silent }) =>
Ix.response({
type: Discord.InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
flags: silent ? Discord.MessageFlag.EPHEMERAL : undefined,
embeds: [embed],
},
}),
Expand Down

0 comments on commit dbd7e4b

Please sign in to comment.