Skip to content

Commit ce06ef0

Browse files
Add private search capability
1 parent 791661f commit ce06ef0

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ docker build . -t tphdocsbot:latest
1818
docker run -e TOKEN=<your discord token> -e APPLICATIONID=<ApplicationID> -e GUILDID=<GuildID> tphdocsbot:latest
1919
```
2020

21-
Or put the values in a local file and use that using..
22-
23-
```console
24-
docker run --env-file .env tphdocsbot:latest
25-
```
26-
2721
### Cofiguration
2822

2923
* `TOKEN` [required] the Discord bot token to run under

src/commands/docs/djs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ const command: Command = {
2929
)
3030
.addChoices(supportedBranches)
3131
.setRequired( false )
32-
),
32+
).addBooleanOption(option => option.setName("private").setDescription("Whether or not to search private elements (default false)").setRequired(false)),
3333
async execute(interaction) {
3434
const query = interaction.options.getString("query");
3535
// The Default source should be stable
3636
const source: keyof typeof sources =
3737
( interaction.options.getString( "source" ) as keyof typeof sources ) ||
3838
"stable";
39-
39+
// Whether to include private elements on the search results, by default false, shows private elements if the search returns an exact result;
40+
const searchPrivate = interaction.options.getBoolean("private") || false;
4041
const doc = await Doc.fetch(source, { force: true });
4142

42-
const resultEmbed = doc.resolveEmbed(query);
43+
const resultEmbed = doc.resolveEmbed(query, {excludePrivateElements: !searchPrivate});
4344

4445
const notFoundEmbed = doc.baseEmbed();
4546
notFoundEmbed.description = "Didn't find any results for that query";

0 commit comments

Comments
 (0)