Discord Autodelete is a Discord bot to configure channels that automatically delete messages after a custom delay, written in Python using discord.py and aiosqlite.
This bot comes with three slash commands:
/autodelete enable <channel> <duration> : Configure a channel for message autodeletion.
/autodelete disable <channnel> : Turn off message autodeletion for a channel.
/autodelete list : List channels with autodeletion enabled.
/autodelete enable
can both initially set up a channel with autodeletion semantics,
and modify previously configured channels. Once autodeletion is enabled in a channel,
any new messages will be deleted on a rolling basis with a delay of duration
after they were sent.
NOTE: Messages already in the channel will not be deleted.
Duration parsing is provided by the pytimeparse library and handles many intuitive time specifications written in natural language (in English). For instance:
/autodelete enable channel: #general duration: 1 day
/autodelete enable channel: #general duration: 20 minutes
/autodelete enable channel: #general duration: 1h, 20m
/autodelete enable channel: #general duration: 01:20:30
/autodelete enable channel: #general duration: 10s
/autodelete enable channel: #general duration: 2.5 weeks
/autodelete enable channel: #general duration: 52 weeks
Good-to-knows:
- There is no (reasonable) limit to duration, though ambiguous units of time such as "months" or "years" cannot be specified directly. Try counting by days instead for very long periods of time.
- The bot handles long durations effectively by storing new messages and their scheduled deletion time in a persistent SQLite database, and incrementally updating it during execution and at startup, based on the bot's last known state.
- Disabling autodelete in a channel cancels all pending deletions.
- Modifying the autodelete timer also cancels deletions, as anything prior to the modification is considered "before the channel was configured," and those messages are never touched.
Discord Autodelete is built for Python 3.9 or later, and is tested on CPython 3.9, CPython 3.11, and PyPy 3.9.
As there is no public bot instance, to host your own instance of the bot:
- Install Python if you don't already have it.
- Run
git clone https://github.com/Eta0/DiscordAutoDelete
if you havegit
installed, or download and unzip the zipped repository through a web browser. - Open that directory.
- Register an application through Discord's developer portal.
- Find your Application ID on the "General Information" page,
- Find your Token on the "Bot" page (you may need to press "Reset Token" to view it),
- Open the file named
.env
and paste the Token onto the end of the first line, afterAPI_TOKEN=
- In the same file, paste the Application ID onto the end of the second line, after
APPLICATION_ID=
. No quotation marks are needed around either. - Join the bot to your server(s) of choice by navigating to the "OAuth2 / URL Generator" page,
checking
bot
, and in the "Bot Permissions" matrix checkingRead Messages/View Channels
,Read Message History
, andManage Messages
, and then navigating to the generated URL. - (Optional) Uncheck "Public Bot" on the "Bot" page if you want to be the only one who can use the link generated in step 5.
- In a terminal opened to the bot installation directory, run
python -m pip install -e .
. - Launch the bot by running
python -m discord_autodelete
or simplydiscord-autodelete
(note the dash on the second one).
Run python -m discord_autodelete --help
for more information about launch options. Notably:
IMPORTANT: You need to launch the bot at least once with the
--sync
flag (python -m discord_autodelete --sync
) for commands to appear in your server(s).
Bonus: Replace the installation command with python -m pip install -e .[speed]
for more efficiency, with extra dependencies.
Discord Autodelete is free and open-source software provided under the zlib license.
- This project is not affiliated with Discord Inc.