English | 日本語
A Discord bot that periodically deletes messages in designated channels.
- Set target channels for deletion
- Remove channels from deletion targets
- Set exclusions
- Remove exclusions
- View settings within the server
- Delete all messages in a channel
Set the channels to be monitored. To prevent accidental deletions, a confirmation message is displayed after executing the command. Press the Ok button within 10 seconds to complete the setting. If the same channel is set again, the setting will be overwritten. Note that messages with exclusion settings will not be deleted.
/enable [#target_channel] [lifetime]
Enter the target channel in the form of a channel mention (#channel_name). This is a required parameter.
Specify how long the messages should remain. Enter the lifetime as a string as shown below.
Input | Abbreviation | Duration |
---|
| 1week | 1w| 1 week | | 1day | 1d | 1 day (24 hours) | | 1hour | 1h | 1 hour | | 1min | 1mi | 1 minute | | 1sec | 1s | 1 second |
You can also specify multiple combinations.
Input | Duration |
---|---|
"1week 2day 3hour 4min 5sec" | 9 days 3 hours 4 minutes 5 seconds |
"1 day 1 hour 30 min" | 1 day 1 hour 30 minutes |
"90mi" | 1 hour 30 minutes |
"1h90mi" | 2 hour 30 minutes |
This is an optional parameter. If omitted, "1day" will be set by default.
Remove channels from the monitoring targets.
/disable {#target_channel}
Enter the target channel in the form of a channel mention (#channel_name). This is a required parameter.
Exclude messages from deletion by specifying the message URL or message ID.
/exclude add [msgurl]
Specify the message URL. This is a required parameter.
Remove the set exclusion settings. To prevent accidental deletions, a confirmation message is displayed after executing the command. Press the Ok button within 10 seconds to complete the setting.
/exclude remove [msgurl]
Specify the message URL. This is a required parameter.
Display the current settings in the server.
/setttings [channel]
This is an optional parameter. If omitted, all settings within the server will be displayed.
Delete all messages in the specified channel. To prevent accidental deletions, a confirmation message is displayed after executing the command. Press the Ok button within 10 seconds to complete the setting.
/clear {#target_channel}
Enter the target channel in the form of a channel mention (#channel_name). This is a required parameter.
The bot requires the following permissions.
Permission Name | Description |
---|---|
Manage Messages | Required to access and delete messages in the target channels |
Read Message History | Required to delete messages sent before the bot was added |
The bot collects the following data for its operation.
Data Target | Data Content |
---|---|
Server ID, Channel ID | Used to identify the target server and channels |
Message ID | Used to set exclusions (the content of the messages or reactions are not read) |
For security reasons, only users with the role "message_cleaner_admin" are allowed to operate this function. The Bot does not automatically generate this role, so an administrator must create it and assign it only to trusted individuals. Even if the "message_cleaner_admin" role exists, deletion commands cannot be used unless the command executor has message management permissions. Therefore, it is recommended to grant message management permissions to that role.
The basic settings are summarized in the devcontainer.
- Clone the source using git
- Prepare environment files in the config folder
- .env (copy .env.example)
- .env.db.production (copy .env.db.production and edit the DB connection information)
- .env.testing (copy .env.example)
- Open with VSCode and select "Reopen in Container"
You can run the debugger directly from the "Run" tab as .vscode/launch.json is provided.
We use pytest and pytest-asyncio. These environments are automatically created during the devcontainer setup, so you can run tests from the "Test" tab.
We use docker-compose. Note: We plan to migrate to k8s in the future.
Start production environment
sh prod.up.sh
To clear cache and start
sh prod.up.nocache.sh
To stop
sh prod.down.sh
- A Python wrapper for the Discord API.
- GitHub: https://github.com/Rapptz/discord.py
- License: MIT License
- A library to read key-value pairs from a .env file and set them as environment variables.
- GitHub: https://github.com/theskumar/python-dotenv
- License: MIT License
- A fast PostgreSQL database client library for Python/asyncio.
- GitHub: https://github.com/MagicStack/asyncpg
- License: Apache License 2.0
- A SQL toolkit and Object Relational Mapper for Python.
- GitHub: https://github.com/sqlalchemy/sqlalchemy
- License: MIT License
- A simple Rust-like Result type for Python.
- GitHub: https://github.com/dbrgn/result
- License: MIT License
- A mature full-featured Python testing tool.
- GitHub: https://github.com/pytest-dev/pytest
- License: MIT License
- A Pytest plugin to support asyncio.
- GitHub: https://github.com/pytest-dev/pytest-asyncio
- License: Apache License 2.0
- A thin wrapper around the mock package for easier use with Pytest.
- GitHub: https://github.com/pytest-dev/pytest-mock
- License: MIT License