Crates.io | discord-retention-bot |
lib.rs | discord-retention-bot |
version | 1.0.2 |
source | src |
created_at | 2020-12-11 12:54:43.82718 |
updated_at | 2020-12-15 10:08:15.678422 |
description | A bot that allows you to set a message retention for individual Discord text channels. |
homepage | |
repository | https://github.com/bahlo/discord-retention-bot |
max_upload_size | |
id | 321827 |
size | 69,933 |
A bot that allows you to set a message retention for individual Discord text channels.
#general
for two weeks, but
#random
for one day)Before running your bot you need to create it on Discord:
Bot
and click Add Bot
and make sure to uncheck Public bot
CLIENT ID
from the General Information
tab74752 is the bitmask for the following permissions:
You can verify this by checking these in the Bot Permissions mask on your bots page.
Go to the GitHub Releases and download the binary for your architecture.
You can use the provided Docker image at
docker.pkg.github.com/bahlo/discord-retention-bot/discord-retention-bot:1.0.2
.
Run cargo install discord-retention-bot
to install the latest version from
crates.io.
git clone https://github.com/bahlo/discord-retention-bot
cargo build --release
to build your binary to
target/release/discord-retention-bot
Configure your bot via environment variables (optionally in an .env
file).
RUST_LOG
Tihs defines the log level. I recommend setting this to
discord-retention-bot=info
for normal usage.
DISCORD_TOKEN
The token of your Discord bot. Get it from the Discord Developer Portal by going to your application → Bot and copying the token.
DELETE_PINNED
Can be set to true
or false
. If set to true
, pinned messages
will also be deleted. Defaults to false
.
CHANNEL_RETENTION
A list of channel names and the duration after which messages should be deleted,
separated by a comma. You can also configure *
to match all unconfigured
channnels.
The duration is a number followed by one of h
(hours), d
(days), and w
(weeks).
Please note that this configuration applies to all guilds your bot is added to.
general:2w,random:4d,*:4w
will result in messages being deleted in
general
: after two weeksrandom
: after four daysDiscord might be rate-limiting you. This applications uses the single message delete endpoint because Bulk Delete Messages doesn't support messages older than 2 weeks. It might take a while the first time, but it will get faster.
Make sure the bot has access to that channel in the Discord application and the following permissions:
To run integration tests you need to create a bot (see Preparation), but with the bitmask 76816, which translates to:
Export the bot token to INTEGRATION_DISCORD_TOKEN
and run cargo test -- --ignored
to run the integration tests.