A self-hosted Discord bot, made compatible with dokku
& docker
for easy deployment!
CleanChat ACC (AutoClearChannel),
is a simple self-hosted Discord bot which can automatically delete messages after a certain delay in a channel.
It also includes a purge
command for easily purging loads of messages really quickly.
The bot itself is a replacement for the AutoClearChannel in CleanChat.
Here is a small tutorial video showing what AutoClearChannel can do,
and how to make a server via the hosting service with no prior knowlegde of the bot.
Authors
- CleanChat ACC: @AlexanderNorup
dokku
&docker
support: @Rikj000
WARNING: The bot is self-hosted meaning that you will have to host it yourself!
There are multiple options for self-hosting:
- Create a new application on the Discord Developer Portal
- Configure your new application as following:
- Go to Bot
- Click
add bot
- Disable
public bot
- Enable all
Privileged Gateway Intents
- Click
- Go to OAuth => URL Generator
- Select Scopes:
bot
- Select Bot Permissions:
Manage Webhooks
Read Messages/View Channels
Send Messages
Send Messages in Threads
Manage Messages
Manage Threads
Read Message History
- Copy the Generated URL & use it to add your Bot to your server
- Select Scopes:
- Go to Bot
- Make sure you have
docker
installed on your server. - Download the latest CleanChat AutoClearChannel Docker
- Unzip the
.zip
package on your computer. - Copy & rename the
config.json.sample
file toconfig.json
. - Configure the newly renamed
config.json
file, make sure to replace yourDISCORD_BOT_TOKEN
.
(See: Configuration) - Build the
docker
container, from command line in the root directory of CleanChat ACC Docker:# Build & tag the CleanChat-ACC container docker build --no-cache -t clean-chat-acc .
After the configuration you can run your container using:
# Run the CleanChat-ACC container with a custom name
docker run -it --name clean-chat-acc clean-chat-acc
dokku
is an awesome tool to deploy software to docker
containers hosted on a server,
all with a simple git push
!
On your server:
- Make sure you have
dokku
&docker
installed on your server. - Create a new (empty)
dokku
app using:dokku apps:create clean-chat-acc
(Or any other name you like)
On your client PC:
- Make sure you have
git
installed on your client PC. - Download the latest CleanChat AutoClearChannel
Docker
- Unzip the
.zip
package on your computer. - Copy & rename the
config.json.sample
file toconfig.json
. - Configure the newly renamed
config.json
file, make sure to replace yourDISCORD_BOT_TOKEN
.
(See: Configuration) - Initialize & configure a
git
repository from command line in the root directory of CleanChat ACC Docker:# Initialize a git repository git init # Connect your git repository to your remote dokku server (Replace <DOKKU_SERVER_IP> with yours) git remote add clean-chat-acc dokku@<DOKKU_SERVER_IP>:clean-chat-acc
After the configuration you can start to commit & push changes from your client to your dokku
server as following:
# Add all files (with changes) in the directory to the git repository
git add .
# Give your changes a proper name
git commit -m "⚡️ Updated `config.json`"
# Push & deploy the changes on your master branch to your dokku server
git push clean-chat-acc master
- Make sure you have .NET 6.0 installed on your server:
- Download the latest CleanChat AutoClearChannel
Portable
orWindows
- Unzip the
.zip
package on your computer. - Copy & rename the
config.json.sample
file toconfig.json
. - Configure the newly renamed
config.json
file, make sure to replace yourDISCORD_BOT_TOKEN
.
(See: Configuration) - Run the execute-able from command line in the root directory of CleanChat ACC:
- Portable:
dotnet CleanChat-AutoClearChannel.dll
- Windows 64 & 32:
CleanChat-AutoClearChannel.exe
- Portable:
Latest version is: v1.0.6.0
Version | Download Link |
---|---|
Docker | CleanChat-AutoClearChannel-Docker-Latest |
Portable | CleanChat-AutoClearChannel-v1.0.6.0-Portable-DotNet-6.0.zip |
Windows 64 | CleanChat-AutoClearChannel-v1.0.6.0-Win-x64.zip |
Windows 32 | CleanChat-AutoClearChannel-v1.0.6.0-Win-x86.zip |
The Portable build runs on all systems, but requires .NET 6.0.
For native Linux users, you can download a free CleanChat-Auto-Updater-Script.sh that will keep the bot updated.
Download and save as CleanChat-Auto-Updater-Script.sh
, and launch that when you run the server.
The Windows builds obviously only runs on Windows, however they don't require .NET 6.0.
The drawback is then that the file-size is a lot bigger.
The bot is configured through the config.json
file, placed in the same root directory as the execute-able.
The config.json
file looks like as following, make sure to replace DISCORD_BOT_TOKEN
with the bot-token of your Discord application:
{
"bottoken": "DISCORD_BOT_TOKEN",
"statusText": "AutoClearChannel provider",
"outputJsonLog": false
}
Here's a table of all the properties of the config.json
file:
Property | Value Type | Description |
---|---|---|
bottoken | Discord Bot Token | Your token from the Discord Developer Portal |
statusText | string | What the bot will be apearing to be "playing" |
outputJsonLog | boolean | If set to true, the log will be displayed in JSON format |
Below you'll find a long list of commands.
If you click on a command,
you'll be taken to an explanation of that command,
along with use cases for set command.
All commands needs to start with you tagging your bot.
This means you have to put @YourBotName#1234
in front of every command, before it works!
Command | Description |
---|---|
help |
Displays info about the usage of all available commands |
autoclearchannel |
Automatically clean your channels |
status |
Shows current settings |
reset |
Resets settings |
forcepublicreply |
Answers to your commands in the channel instead of DM |
purge |
Mass-delete commands |
Displays info about the usage of all available commands.
Usage:
@Bot help
Aliases: autoclearchat
, acc
This command can be used to automatically clear a channel after a specified time.
That means if you set it at 5 seconds,
then the bot will delete every message after they have each spent 5 seconds in chat.
The delay is set in milliseconds or a "formatted time string"
"Formatted time strings" looks like this:
Format | Meaning |
---|---|
2s |
"2 Seconds" |
5m1s |
"5 Minutes and 1 Second" |
10h6m10s |
"10 Hours, 6 Minutes and 10 seconds" |
2s500ms |
"2 Seconds and 500 Milliseconds" |
So basically a number, and then a letter representing a time unit.
Format | Meaning |
---|---|
ms |
"Milliseconds" |
s |
"Seconds" |
m |
"Minutes" |
h |
"Hours" |
d |
"Days" |
If you want to remove a autoclearchannel again, you must either set the deletion delay to 0 or use reset
.
Usage:
@Bot autoclearchannel <#channel> <time in ms | formatted time string>
Show/hide argument information
Example of used correctly:
@Bot autoclearchannel #channel 5s
Shows current configuration of the bot.
Usage:
@Bot status
The bot forgets everything about your server.
Can be used if you want to start-over.
Usage:
@Bot reset
Aliases: fpr
If enabled, the bot will always reply in chat, instead of in DM's.
This feature is useful if you don't want people on your server to be able to DM you,
but you still want to use the bot.
Usage:
@Bot forcepulicreply <true | false>
Show/hide argument information
Example of used correctly:
@Bot forcepublicreply true
Aliases: p
Will delete set number of messages from chat.
You can only delete a maximum of 100 messages per command execution.
The bot will skip any pinned messages.
If a user is specified, the bot will only delete messages sent by that user.
Filters: This command supports filters. The following filters are available:
Filter | Usage | Description |
---|---|---|
contains | contains:<string> |
Deletes the message if it contains the |
startswith | startswith:<string> |
Deletes the message if it starts with the |
endswith | endswith:<string> |
Deletes the message if it ends with the |
withimage | withimage |
Deletes the message if it has an image attached |
withoutimage | withoutimage |
Deletes the message if it does not have an image attached |
regex | regex:<regex> |
Deletes the message if it matches the (Advanced) |
Note: The bot can only mass-delete messages that're under 14 days old.
This is a limitation set by Discord, which I can't do anything about, even if I wanted.
Usage:
@Bot purge <number> [user | filter] [filter]
Show/hide argument information
Examples of used correctly:
@Bot purge 50
@Bot purge 25 @UserName#1234
@Bot purge 25 contains:banana