A discord bot that allows you to set a retention for different channels (similar to Slack).
Before running your bot you need to create it on Discord:
74752 is the bitmask for the following permissions: * View Channels * Manage Messages * Read Message History
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.1
.
Run cargo install discord-retention-bot
to install the lates 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
Configuration is happening via environment variables or an .env
file:
RUST_LOG
defines the log level (I recommend setting this to
discord-retention-bot=info
)DISCORD_TOKEN
is the token of your Discord botCHANNEL_RETENTION
is a list of channel names and the duration after which
messages should be deleted, separated by a comma.
Example: general:2w,random:4d
(currently the duration only supports h
, d
and w
, please open an issue
if you need another one). Please note that this applies to all guilds your
bot is added toDELETE_PINNED
can be set to true
or false
(default). If set to true
,
pinned messages will also be deletedDiscord 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: * Read Text Channels & See Voice Channels * Manage Messages * Read Message History
Check the Cargo.toml for all packages used in this project. I just want to highlight serenity, a great library for interacting with the Discord API.