Skip to content

Commit

Permalink
Refactor example.env: Add COMMAND_NAME to allow users to set their ow…
Browse files Browse the repository at this point in the history
…n commands name
  • Loading branch information
jamcalli committed Oct 3, 2024
1 parent be1303c commit 9a00dda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Set the following environment variables:
- `PLEX_TOKEN`: This is your X-Plex-Token. Find out how to get yours [here](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/).
- `PLEX_LIBRARY_NUM`: This is the library section number. It can be found by going to the following URL: `http://[PMS_IP_Address]:32400/library/sections?X-Plex-Token=YourTokenGoesHere`. Replace `YourTokenGoesHere` with your token from above. Note the `key="number"` of your audiobook library. That number goes here.
- `AUDIOBOOK_BAY_URL`: Different regions have different base urls. See which one works for you and enter it here (eg. https://audiobookbay.lu).
- `COMMAND_NAME`: Whichever command name you want for the command. Defaults to scrape (accessed by /scrape within discord).

Your `.env` file should look something like this:

Expand All @@ -68,6 +69,7 @@ PLEX_HOST=YOUR_PLEX_HOST
PLEX_TOKEN=YOUR_PLEX_TOKEN
PLEX_LIBRARY_NUM=YOUR_PLEX_LIBRARY_NUM
AUDIOBOOK_BAY_URL=WORKING_ABB_URL
COMMAND_NAME=COMMAND_NAME_OF_YOUR_CHOICE
```
5. `docker compose pull && docker compose up -d`

Expand Down
9 changes: 8 additions & 1 deletion src/commands/commands/scrape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ import { fixCoverUrls, trimSearchResults } from "../../utils/validation.ts";
import { logger } from '../../bot.ts';
import { bookBrowser } from "../../events/bookbrowser.ts";
import { SearchResultItem } from "../../interface/scrape.interface";
import dotenv from 'dotenv';

// Load environment variables from .env file
dotenv.config();

// Get the command name from the environment variable
const commandName = process.env.COMMAND_NAME || 'scrape';

// Define the command data
const data = new SlashCommandBuilder()
.setName("scrape")
.setName(commandName)
.setDescription("Validate spelling. Start with Author.")
.addStringOption(option =>
option.setName("author")
Expand Down

0 comments on commit 9a00dda

Please sign in to comment.