An efficient Discord Bot to prevent spam written in C++. Tested on a large discord server and mitigates around 90% spam. Its well commented and can be easily adapt according to your needs.
The following is considered as spam and will be deleted by the bot:
- discord invitations
- crossposted messages (repeated messages over too many channels). This also effects fake nitro ads!
- repeated messages
- messages with too many mentions
- bad words (configurable in
- messages that contain blacklisted domains as a url (see
- forbidden file extensions like .exe (configurable)
The bot will time out users who spam!
Currently only Linux is supported, but other UNIX-style platforms should build and run the bot fine.
mkdir build cd build cmake .. make -j8
Replace the number after -j with a number suitable for your setup, usually the same as the number of cores on your machine.
Visit the D++ library documentation for more details.
config.json. The configuration variables in the file should be self-explanatory.
All bad words are saved line by line in the
bypass-config.txt can be used to exclude users and roles from getting detected by the bot, just save the user- and role IDs line by line in it.
All forbidden domains are stored in
domain-blacklist.txt. Used to prevent the sharing of certain websites/urls. You can also add top-level-domains to them.
The bot creates discord slash commands to manage the above three .txt-configs, therefor they're stored in extra files.
The bot requires the message content and server members intent to be enabled! Add the bot with the
applications.commands scope to your server! The bot needs the following permissions:
I'd recommend running the bot with systemd, to keep the bot always online.
A basic unit file could look like this:
[Unit] Description=Antispam Discord Bot After=network.target [Service] ExecStart=/home/PATH_TO_THE_EXECUTABLE Type=simple Restart=always [Install] WantedBy=multi-user.target
Show your support
Be sure to leave a
I had pretty much the same bot in python, but I had problems with the message cache when it ran on a bigger discord server. Weird things happened and in the end i had no real control of the cache, so i moved to C++.