Best Discord Bot For Moderation

 
import os
import discord
from discord.ext import commands
from better_profanity import profanity
import logging
import asyncio

bot_token = os.environ['DISCORD_BOT_TOKEN']
host_id = os.environ['DISCORD_HOST_ID']

bot_prefix = '!'

intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
intents.guilds = True
intents.dm_messages = True

bot = commands.Bot(command_prefix=bot_prefix, intents=intents)

# Set up logging to output to console instead of a file due to permission issues
logging.basicConfig(level=logging.INFO, format='%(asctime)s:%(levelname)s:%(name)s: %(message)s')
logger = logging.getLogger('discord')

About this template

The Discord bot monitors all messages in the server. If a message contains profanity, the bot deletes it and sends a warning to the channel. The bot also notifies the host about the deletion via a direct message. Additionally, the bot outputs a helpful error message to a channel if there is a permissions error, guiding the server admin to enable the required permission in the Discord Developer portal.

Introduction to the Discord Moderation Bot Template

Welcome to the step-by-step guide on how to use the Discord Moderation Bot template on Lazy. This template provides a pre-built Discord bot that monitors messages for profanity. When it detects inappropriate language, it automatically deletes the message and notifies the channel and the host. This guide will walk you through the process of setting up and deploying this bot on your Discord server.

Clicking Start with this Template

To begin, click on the "Start with this Template" button. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy or paste any code manually.

Initial setup: Adding Environment Secrets

Before testing the bot, you need to set up two environment secrets within the Lazy Builder:

  • DISCORD_BOT_TOKEN: This is the token you receive from the Discord Developer Portal when you create a new bot. It allows the bot to connect to the Discord API.
  • DISCORD_HOST_ID: This is the Discord user ID of the host who will receive notifications about deleted messages. You can find your user ID by enabling Developer Mode in Discord, right-clicking your username, and selecting "Copy ID".

To add these secrets, navigate to the Environment Secrets tab within the Lazy Builder and enter the respective values for each secret.

Test: Pressing the Test Button

Once you have set up the environment secrets, press the "Test" button. This will begin the deployment of the bot and launch the Lazy CLI. The bot will start running on the Lazy platform without the need for any local setup.

Using the App

After deployment, your Discord Moderation Bot will be active on your server. It will monitor messages in real-time and delete any that contain profanity. When a message is deleted, the bot will send a warning to the channel and notify the host via a direct message.

Integrating the App

To integrate the bot into your Discord server, you need to invite the bot to your server using the link provided by the Discord Developer Portal where you created your bot. Make sure to grant the bot the necessary permissions, such as "Manage Messages", to allow it to delete messages and function properly.

Remember to keep the bot's token and your user ID confidential to ensure the security of your bot and server.

By following these steps, you will have successfully set up and deployed the Discord Moderation Bot using the Lazy platform. Enjoy a cleaner and more professional environment on your Discord server!

Technology
Last published
June 15, 2024

More templates like this

Discord Ticketbot Template

A simple Discord Ticketbot for your Discord Support Department. This Template and Bot is fully customizable but already build so that you can use it right away. You need a bot token from https://discord.com/developers/applications for your bot to work. These are the steps needed to get your token: "1. 🌐 Go to the Discord Developer Portal. 🌐\n" + "2. 🆕 Create a new application and navigate to the 'Bot' section. 🤖\n" + "3. 📋 Under the 'TOKEN' section, click 'Reset Token' to get your Discord bot token and confirm by clicking 'Yes, do it'. 🔑\n" + "4. 🤖 If your bot will have any ability to read/reply to messages, then under the 'BOT' section, enable the slider titled 'Message Content Intent' ✅" + "5. 🔐 Set the 'DISCORD_BOT_TOKEN' in the Env Secrets tab with your bot token from step 3. 🔐\n" + "For bot permissions, it's recommended to start with basic permissions and adjust as needed for your app's functionality.🚀") If you encounter any bugs, please tell Lazy to fix them and report them on the Official Lazy AI Discord to @D4vidG4merLP. Credits: @meow - the Discord bot slash command template @mrlazy.notlazy - supporting me And the Biggest Thank you. You for using this template ❤️

Discord

Discord bot using slash commands in python

Just a cute /ping bot

Discord
Python
Flask

Basic Discord Bot

A Discord bot that does nothing (excellent starting point). Think of it as the plain paper of Discord bots. It does nothing at all and you can turn it into whatever you want. All you need to set is a Discord bot token from your Discord developer portal and boom! You're done.

Discord
Python
Home
/
Best Discord Bot For Moderation