rickstaa / warnings-discord-bot

A Go-based Discord bot that monitors chat messages for specified keywords and conditions, issuing automated warnings to maintain a respectful and safe chat environment
MIT License
1 stars 0 forks source link
bot discord moderation warnings

Docker Build Publish Docker image Docker Image Version (latest semver) Latest Release

Warnings Discord Bot


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.

image

Features

Prerequisites

Before you can run the bot, make sure you have the following:

How to Use

Run bot locally

  1. Clone this repository to your local machine.
  2. Modify the config.json file to include the keywords you want to monitor and the warning messages you want to send in response to keyword matches.
  3. Setup a discord application (see this guide). Ensure that the message content and guild members intents are enabled. Also, ensure that the Send Messages and Read Message History permissions are requested on the URL Generator step.
  4. Install the Golang dependencies using go get.
  5. Build the bot using go build
  6. Rename the .env.template file to .env and insert the required environmental variables.
  7. Run the bot using ./warnings-discord-bot.

Running the bot with Docker

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.

Configuration

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:

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.

Contributing

We welcome contributions 🚀! Please see our Contributing Guide for more details.

License

This project is licensed under the MIT License.