Warnings Discord Bot is a Discord bot written in Go that monitors messages for specific keywords or regular expressions and responds with warning messages. It can also send a welcome warning message to new members. It is designed to help maintain a respectful and safe chat environment within your Discord server. This bot was developed to overcome specific limitations in Discord Automod, such as the absence of an account age filter and the lack of a warning message options for 'Block Custom Words'. Further information can be found in the related community discussion here and the feature request here.
Before you can run the bot, make sure you have the following:
Send Messages
and Read Message History
permissions are requested on the URL Generator step.go get
.go build
.env.template
file to .env
and insert the required environmental variables../warnings-discord-bot
.The Warnings Discord Bot can be run using the Docker image available on Docker Hub. To pull and run the bot from Docker Hub, use the following command:
docker run --name warnings-discord-bot rickstaa/warnings-discord-bot:latest
Please ensure you have a .env
file in the current working directory containing the required environmental variables. You can find an example of this file here or add the DISCORD_BOT_TOKEN
as an environmental variable to the docker run
command.
[!NOTE] This repository also contains a DockerFile and docker-compose.yml file. These files can be used to build and run the bot locally. To do this, clone this repository and run
docker compose up
in the repository's root directory.
The bot's behaviour can be customized through the config.json file. This JSON file contains several fields that define the bot's keyword and regular expression monitoring, response behaviour, and join warning message.
Here's a breakdown of the fields:
join_warning_message: A string that defines the message the bot will send to a user when they join the server. If this field is empty, no message will be sent.
alert_rules: An array of objects, each representing a unique alert rule. An alert rule defines conditions that, when met, trigger a bot warning. Each object has the following properties:
true
, the bot will only issue a warning if the message contains both the specified keywords or regular expressions and an external link.Please note that all keyword and regular expression comparisons performed by the bot are case-insensitive.
[!IMPORTANT]\ Remember to escape backslashes when writing regular expressions in the JSON configuration file. For example,
\b(word)\b
should be written as\\b(word)\\b
.
We welcome contributions 🚀! Please see our Contributing Guide for more details.
This project is licensed under the MIT License.