/discord-digest

Discord Email and Web Digests

Primary LanguagePythonMIT LicenseMIT

License: MIT


Logo

Discord Digest

Your Discord server's most important Discord messages in email or web format.
Explore the docs »

Contribute · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Discord moves fast, this project aims to help your community not miss the important stuff by compiling the most important / popular messages into json format for use in email templates, web pages, and more!

(back to top)

Built With

  • Python

(back to top)

Getting Started

Prerequisites

Create a virtual environment (I enjoy using pyenv-virtualenv)

  • pyenv
    pyenv virtualenv 3.10.x discord-digest-env

Section 1 - Creating the Bot

Steps

  1. Log in to the Discord Developer Portal and create a new application.
  2. Give your application a name and click "Create". We reccomend the name ServerDigest-bot.
  3. In the application dashboard, navigate to the "Bot" section and click "Add Bot".
  4. Generate a TOKEN by clicking the "Reset Token" button. Copy the token and add it to your .env file at the root of your repo. Make sure to keep this a secret.
  5. On the same "Bot" page, activate "Message Content Intent" button slider. Note: This setting is required for your bot to receive message content in most messages.
  6. Navigate to the OAuth2 tab and click URL Generator. On this page, select the "bot" scope and "administrator" bot permissions.
  7. Copy the Generated URL to be used in step 8.
  8. Navigate to General within the OAuth2 section, underneath the "Default Authorization Link" section, select "Custom URL" and paste URL from step 7. Click "Save Changes".
  9. Load this URL in a new tab and select which of your servers you want to install the bot in. Follow GUI instructions to Authorize.
  10. That's it! The bot is ready to be used by the codebase.

Section 2 - Enable Discord Developer Mode

  1. Open up the Discord app (Desktop or Web)
  2. Click on User Settings cog button
  3. Under the APP SETTINGS section click "Advanced"
  4. Toggle "Developer Mode" on

Section 3 - Setting up the Repo

  1. Clone this repo

    git clone https://github.com/skyforest/discord-digest.git
  2. Activate the virtual environment you created from the Prerequistes section

  3. Install Python packages

    pip install -r requirements.txt
  4. To get the guild ID of the guild you added your bot to, right click the guild icon on the left panel of discord and click "Copy ID". Add this value to your .env file.

  5. To get the channel ID, right click each channel name in Discord and click "Copy ID". Add the ID (or multiple ID's in list format) to your .env file in the format below.

  6. Configure the following environment variables in a local .env:

    DISCORD_TOKEN="PASTEYOURTOKENHERE"
    GUILD_ID=010101010101010101010101010101
    CHANNEL_IDS=0000000000000,0000000000000000
    COLLECTION_METHOD='COLLECT_MOST_REACTIONS'

    NOTE: COLLECTION_METHOD can be set to one of the following: 'THREADS' 'CUSTOM_EMOJI' 'COMBO_THREADS_CUSTOM_EMOJI' 'COMBO_THREADS_MOST_REACTIONS' 'COLLECT_MOST_REACTIONS'

  7. Add the Guild Role and ServerDigest Emoji by running the script once:

 python app.py

Running this script for the first time, you will see the messages:

  • "Custom role was not found - it has now been added. Mark your messages with the custom emoji and run again."
  • "Custom emoji was not found - it has now been added. Mark your messages with the custom emoji and run again." That's expected. Your Guild should now have a role called serverdigest_admin and the custom emoji :add_to_digest: automatically added.
  1. Assign the serverdigest_admin role to any users who should have permission to mark messages with the ServerDigest emoji. The emoji will only become available for use to these specific users. (May require app to be reloaded for emoji to show up)

(back to top)

Section 4 (optional) - Sendgrid

  1. Sign up for Sendgrid
  2. Generate API key and copy/paste into your .env as SENDGRID_API_KEY=<YOUR_SENDGRID_API_KEY_HERE>
  3. Make sure sendgrid is installed via the requirements file OR run pip install stendgrid

Section 5 - Usage

Message Collection

  1. Mark the messages you want to be collected with the custom :add_to_digest: emoji. Make sure the messages are inside of the channels you added to the CHANNEL_IDS list within your .env file. Messages will be collected from the past two weeks.

  2. cd into collector/ and run the message collection script:

python collector.py

If any messages from your Discord channels met the script criteria, they will appear in the messages.json file.

Render Messages in Digest Template

  1. Edit digest/digest.py and fill in the placeholder variables DIGEST_NAME DIGEST_BLURB.

  2. cd into digest/ and run:

python digest.py
  1. Your newly generated digest html file will be available in digest/digests/. You can open that file in your browser to see how things look.

Send the digest as an email

  1. Open and edit mailroom/send_digest.py and fill in the placeholder values target_digest, from_email, to_emails, and subject.

  2. cd into mailroom/ and run:

python send_digest.py

(back to top)

Troubleshooting

Coming soon...

Roadmap

  • Coming Soon...

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Cody Antunez - Twitter: @skyforest - email: cody.antunez@gmail.com - Blog: codyantunez.com

Project Link: https://github.com/skyforest/discord-digest

(back to top)

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

(back to top)

Buy Me a Coffee

"Buy Me A Coffee"