# PYRSS Website ## Setup ### Discord Application A Discord Application is required for PYRSS to work, as it will provide the Discord Bot used to send RSS content. Save the key and secret as these environment variables: - `DISCORD_KEY` - `DISCORD_SECRET` #### Create the Application 1. Navigate to the Discord Developer Portal, on the applications page: https://discord.com/developers/applications. 2. Create an App using the "New Application" button. #### Installation Now that you've created an Application, there are some required settings that you need to configure, navigate to the "Installation" tab from the sidebar. Under "Installation Contexts", ensure that only the `Guild Install` checkbox is checked. ![An example image showing the "Guild Install" checkbox as checked.](apps/static/images/installation_contexts.png) This application is designed to be used in Guilds, so this setting is important. #### OAuth2 Navigate to the "OAuth2" tab from the sidebar. 1. Head to the "Redirects" section and select "Add Redirect" 2. Add a redirect with this format: `PROTOCOL://HOST_ENDPOINT/oauth2/login/redirect` where `PROTOCOL` is either `http` or `https`, and the `HOST_ENDPOINT` is either an IP:PORT combination or web domain. Now you need to generate an Invite URL that you can use to add the Bot to your Discord Server. Navigate to the "OAuth2 URL Generator" section. 1. Check the checkboxes for these scopes: - identify - guilds - applications.commands - bot 2. There should be a select box below the "scopes" section. Select the redirect URL that you created earlier. 3. Check the checkboxes for these bot permissions: - View Channels - Send Messages - Embed Links - Attach Files > TODO: verifiy? - Use Slash Commands 4. "Integration Type" select `Guild Install` 5. Copy and save the generated URL You need to create an environment variable for the generated url, `DISCORD_OAUTH2_URL`. > TODO: write for `DISCORD_INVITE_URL` env var #### Bot Navigate to the "Bot" tab from the sidebar. Take note of the Token, you may need to use the "Reset Token" button to get one. You will need to create an environment variable `BOT_TOKEN` for PYRSS. Navigate to the "Privilaged Gateway Intents" and ensure these intents are enabled: - > TODO ### Database Use environment variables to specify a database, otherwise an sqlite database file will be created and used by default. #### Environment Variables `DB_ENGINE` - [Supported database engines](https://docs.djangoproject.com/en/5.0/ref/settings/#engine) `DB_NAME` - Name of the database `DB_USER` - Name of the database user `DB_PASS` - Password of the database user `DB_HOST` - Host IP of the database `DB_PORT` - Host Port of the database > **Note** > If `DB_ENGINE` is not specified, the other database related environment variables will be ignored, and the default sqlite database will be used with a generated `db.sqlite3` file. ### Admin Account Create an environment variable `SUPERUSER_IDS` and add comma separated Discord snowflake User IDs. When logged-in, these users will be able to access the admin panel. ## Logs By default, logs will be output to the `logs/` directory in the project root, which is at `/app/logs/` when deployed with docker. ## Troubleshooring ### Bad Request (400) Ensure your `HOST` environemtn variable matches the endpoint that you are accessing the web application from. ### Server Error (500) - keyerror 'access_token' Ensure your environment variables for `DISCORD_OAUTH2_URL` and `DISCORD_REDIRECT_URL` are correct, using the correct endpoint for your application, otherwise discord will not return a response including an access token when requested.