A self-hosted Discord bot for locking and unlocking a channel based on a schedule. This bot can join multiple Discord servers, however, it will work on the same schedule on all of them. Currently, the schedule must be specified in UTC.
Binaries for x64 Linux and Windows are available on the releases page
- Install Rust
- Clone this repository
- Run
cargo run --release
in the cloned repository - Create a Discord API token, add the bot to your server... (there are many guides on how to do that on the internet and I'm not sure whether I should link any of them)
- Modify the created configuration file (a file named
bot.cfg
should appear in your working directory after runningcargo run --release
) - Run
cargo run --release
again
For cross-compilation I recommend cross
- Install cross
- Run
cross build --target arm-unknown-linux-musleabihf --release
, replacearm-unknown-linux-musleabihf
with the target (arm-unknown-linux-musleabihf
is ok for Raspberry Pi 3)
- Download or compile latest version of the bot
- Generate a Discord API token, example tutorial: https://www.writebots.com/discord-bot-token/
- Create a
bot.cfg
file, replaceDISCORD_TOKEN
with the token you got from the tutorial - Start the bot
- Generate and use the bot invitation link (step 5 of the tutorial from step 2). This bot will need permissions for sending messages, managing roles and channels, viewing channels, sending, managing and reading messages.
The bot searches for bot.cfg
in its working directory. An example configuration file will be created when the bot is run for the first time.
discord_token = 'DISCORD_TOKEN' # discord api token
channel_name = 'example-channel' # name of the channel to lock (channel will be created if it doesn't exist)
role_name = 'example-role' # name of the role that should be locked out of the channel
lock_message = 'locked' # message to post when locking the channel (the message will be posted in the channel that's being locked)
unlock_message = 'unlocked' # message to post when unlocking the channel
lock_on = '0 0 0 * * Mon *' # locking schedule in crontab format, ***in UTC***
unlock_on = '0 0 21 * * Sun *' # unlocking schedule in crontab format, ***in UTC***
agressive_lock = true # if enabled, when the channel is locked, the bot will delete all messages posted to that channel
- serenity - library for the Discord API
- job_scheduler- for scheduling tasks
- confy - saving and loading configuration files with serde
- serde - used by confy to serialize and deserialize the configuration file
- chrono - I believe it's needed to use the
upcoming
method ofSchedule
from job_scheduler
- Refactoring
- Managing multiple channels
- Server emojis
agressive_lock
should work only if a user has the role specified in the configuration- Logs
- Daylight saving time
This project is licensed under the MIT License - see the LICENSE.md file for details