Skip to content

Taaku18/discord-message-scheduler

Repository files navigation


Logo

Discord Message Scheduler

GitHub tag GitHub commit activity Forks Stars Issues License Code Factor code quality pre-commit Docker hub Version

A simple Discord Bot that can send scheduled messages.
Explore the docs »

Report Bug · Request Feature

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

About The Project

Schedule creator screenshot

Discord Message Scheduler provides a convenient bot interface to grant users the ability to create scheduled messages via the bot.

(back to top)

Features

  • Supports both prefixed and slash commands
  • Uses SQLite database
  • Modern Discord Modal interface
  • Easy to set up
  • Docker support

Built With

Python discord.py

(back to top)

Getting Started

Follow these instructions to deploy your own Discord Message Scheduler bot.

Prerequisites

This bot is build on Python 3.10. You will need to download the latest version of Python using any of the methods below.

  • From official website (Any OS): https://www.python.org/downloads/.
  • Using Homebrew (MacOS/Linux):
    brew install python@3.10
  • Using APT (Debian/Ubuntu):
    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt update
    sudo apt install python3.10 python3.10-dev software-properties-common
    curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

You will also need a Discord bot.

  1. Create a Discord application at https://discord.com/developers/applications
  2. Within the settings page, navigate to the Bot tab and create a bot
  3. (Optional) If you don't want others to invite your bot, then disable PUBLIC BOT.
  4. Enable SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT under the Privileged Gateway Intents settings
  5. Navigate to Oauth2URL Generator tab, click both bot and applications.commands, and check the following buttons:
    • Read Messages/View Channels
    • Send Messages
    • Send Messages in Thread
    • Send TTS Messages
    • Embed Links
    • Attach Files
    • Read Message History
    • Mention Everyone
    • Use External Emojis
    • Use External Stickers
    • Add Reactions
    • Use Slash Commands
  6. Open the link in the Generated URL box at the bottom to invite your bot.

Installation

  1. Clone or download the repo
    git clone https://github.com/Taaku18/discord-message-scheduler.git
  2. Install Python dependencies, choose a method from below:
    1. (Recommended) Using PDM
      1. Install PDM
      2. Run pdm install --prod -G speed --no-lock --no-editable
    2. Using pip
      python3.10 -m pip install -U pip
      python3.10 -m pip install -U -r requirements.txt
  3. Rename .env.example to .env and replace BOT-TOKEN with your bot's token and BOT-PREFIX with your desired bot prefix. Example .env file:
     TOKEN=VTDkXNDUzC3KyFoIxNzYx2_d4OQ.PK5K1A.9p0q3Kdi26j0eCa_vu3Ke_39KsL3Kkso83E_gB0
     PREFIX=?
     SYNC_SLASH_COMMANDS=on
    SYNC_SLASH_COMMANDS should be set to "on" the first time you start the bot and every time you update. It should be set to "off" during normal usage since syncing slash commands may take a long time.

(back to top)

Usage

To start the bot, simply run:

python3.10 start.py

(back to top)

Docker (experimental)

Docker Pulls Docker Size

Alternatively, you can use Docker to deploy this bot.

Ensure you have the latest version of Docker installed (v19.03.0+). You will also need the Docker Compose Plugin.

Pre-built images are provided at taaku18/dms.

  1. Clone or download the repo
    git clone https://github.com/Taaku18/discord-message-scheduler.git
  2. Rename .env.example to .env and set your environment variables (see step 3 above)
  3. Deploy your bot (this will use the pre-built image provided for amd64 and arm64)
    docker pull taaku18/dms:stable
    docker compose up -d
    If you wish to build your own image instead, replace taaku18/dms:stable with dms:latest in docker-compose.yml. Then run
    docker build -t dms:latest .
    docker compose up -d

You can stop the bot by running docker compose down.

To access your bot logs, run docker ps. This will show a list of containers.

CONTAINER ID   IMAGE            COMMAND             CREATED          STATUS                  PORTS     NAMES
58e6aao4c8bd   dms:latest       "python start.py"   14 seconds ago   Up Less than a second             discord-message-scheduler

Find the CONTAINER ID of the container named "discord-message-scheduler" and run docker logs <CONTAINER ID>.

Docker Tags

  • latest - the most recent commit on main
  • stable - the most recent published tag commit
  • x.y.z - version x.y.z tag commit

The default tag is stable. To use a different tag, replace the "stable" of taaku18/dms:stable with your desired tag in docker-compose.yml.

(back to top)

Commands Guide

This bot accepts both prefixed and slash commands.

Table of Contents
  1. Schedule related:
  2. General:

The default bot prefix is =.

[arg] - Optional
<arg> - Required

/schedule create [channel]

Creates a scheduled message. You can optionally supply a channel argument to specify a channel for the message.

A Discord modal prompt will open, asking for the following:

  • Message - The message that the bot should send at the scheduled time.

  • Scheduled Time - The time to send the message, accurate to the second.

    Formats:

    • Just date: 2/24/2023 (Month/Day/Year), December 12, nov 26 2023
    • Just time: 1:12am, midnight, 13:42, 7pm
    • Date and time: 02/24/23 19:31:03
    • Other date formats: March 30 2023 4:10pm
    • Simple time: tomorrow, next week, thursday at noon
    • Slightly complicated relative time: in 1 day, 2 hours and 10 minutes
    • ISO 8601 format: 2023-08-11T01:59:41.981897
  • Timezone - The timezone to parse your time.

    Formats:

    • Formal TZ database name: America/Los_Angeles, Europe/Berlin, Asia/Shanghai
    • Time zone abbreviation: GMT, UTC, CEST, PDT, EST, ET (not recommended, may be inaccurate)
    • Timezone offset: +12:30, -3000, +0123, UTC+1232, UTC-12:32
  • Repeat - The number of minutes between every repeat of the scheduled message. Set 0 to disable.

/schedule list [channel]

Shows you a list of upcoming scheduled messages. You can optionally supply a channel argument to specify a channel to check for your upcoming scheduled messages.

/schedule show <event-id>

Shows you the full details of a scheduled message. To find the event-id, use the /schedule list command.

/schedule edit <event-id> [new-channel]

Due to limitations with the bot, it is not possible to edit the time or timezone. You will need to delete and re-create the schedule event.

Edits the contents of an upcoming scheduled message. To find the event-id, use the /schedule list command.

To change the current channel, set new-channel to the channel that you want.

/schedule delete <event-id>

Deletes/un-schedules an upcoming scheduled message. To find the event-id, use the /schedule list command.

/info

Shows info about this bot.

=help [category-or-command]

This command is only available as a prefixed command.

Shows the help page. Optionally, set category-or-command to be a category or command name to view more info on the subject.

Note: [category-or-command] is case-sensitive.

(back to top)

Roadmap

  • Basic help and schedule command interfaces
  • Create a Docker image
  • Implement list/delete command
    • Allow server staff access to these commands
  • Implement reporting interface to remove abusive scheduled messages
  • Permissions system
  • Add GitHub workflow for testing, linting, building Docker image
  • Auto generate requirements.txt from PDM using pre-commit
  • Revise pyright config, add to contributing guidelines
  • Replace the README screenshot and add a bot logo

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. If you made any code changes, use black . to format the code
  4. Commit your Changes (git commit -m 'Add some AmazingFeature')
  5. Push to the Branch (git push origin feature/AmazingFeature)
  6. Open a Pull Request

We use PDM as our dependency manager. See their installations page on how to install this tool.

  • Add package: pdm add <package name>
  • Update package: pdm update <package name>
  • Remove package: pdm remove <package name>
  • Install dependencies: pdm sync --clean -G:all (this will also remove all non-project dependencies)

Optionally add -dG <group name> (development group) or -G <group name> (optional group) to the above commands if the package belongs to a specific group (ex. lint, speed).

When making dependencies changes, always export the requirements to requirements.txt with

pdm export --pyproject --without-hashes --prod -G:all -o requirements.txt

To simplify some common processes, such as linting with black and generating requirements.txt, we use pre-commit. It's recommended to install pre-commit by following the quick start guide and run pre-commit run -a to run the pre-commit actions.

(back to top)

License

Distributed under GNU General Public License v3.0. See LICENSE.txt for more information.

(back to top)

Contact

Contact me via Discord:

Taku - taku#3343

Project Link: https://github.com/Taaku18/discord-message-scheduler

(back to top)

Acknowledgments

(back to top)