Multipurpose Discord Bot:

Test this app for free
29
import os
import discord
from discord.ext import commands
import sqlite3
from datetime import datetime, timedelta

intents = discord.Intents.default()
intents.messages = True
intents.members = True
bot = commands.Bot(command_prefix='/', intents=intents)

# Initialize SQLite database
conn = sqlite3.connect('moderation_cases.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS moderation_cases (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER,
    moderator_id INTEGER,
    action TEXT,
    reason TEXT,
    timestamp DATETIME
)
''')
Get full code

Frequently Asked Questions

How can this Multipurpose Discord Bot benefit my online community?

The Multipurpose Discord Bot offers several benefits for your online community. It provides essential moderation tools like kick, ban, and timeout commands, helping maintain a safe and friendly environment. The bot also includes a warning system and case tracking, allowing moderators to keep detailed records of user infractions. Additionally, the bot's ability to send messages and DMs can enhance communication within your server.

Can this bot be customized for different types of communities?

Absolutely! The Multipurpose Discord Bot is designed to be flexible and adaptable. While it comes with built-in moderation features, you can easily extend its functionality by adding new commands or integrating with other services. For example, you could add game-specific commands for a gaming community or educational tools for a study group. The bot's structure allows for easy expansion to meet the unique needs of your community.

How does the moderation case tracking feature help with community management?

The moderation case tracking feature of the Multipurpose Discord Bot is a powerful tool for effective community management. It logs all moderation actions (kicks, bans, timeouts, and warnings) in a SQLite database, allowing moderators to view a user's history with the /modcase command. This helps in making informed decisions about repeat offenders and maintaining consistency in moderation across your team. It also provides transparency and accountability in your moderation practices.

How can I add a custom command to the Multipurpose Discord Bot?

Adding a custom command to the Multipurpose Discord Bot is straightforward. Here's an example of how you could add a simple greeting command:

python @bot.tree.command(name="greet", description="Greet a user") async def greet(interaction: discord.Interaction, member: discord.Member): await interaction.response.send_message(f"Hello, {member.mention}! Welcome to our server!")

Add this code to the main.py file, and the bot will have a new /greet command that mentions and welcomes the specified user.

How does the bot handle errors, such as trying to kick a user with higher permissions?

The Multipurpose Discord Bot includes error handling to manage situations like attempting to kick a user with higher permissions. Here's an example from the kick command:

python @bot.tree.command(name="kick", description="Kick a member from the server") @commands.has_permissions(kick_members=True) async def kick(interaction: discord.Interaction, member: discord.Member, reason: str = None): try: await member.kick(reason=reason) # ... (logging and success message) except discord.Forbidden: await interaction.response.send_message("I don't have the required permissions to kick this user.") except discord.HTTPException: await interaction.response.send_message("An error occurred while trying to kick the user.")

This code catches discord.Forbidden errors (which occur when the bot lacks necessary permissions) and discord.HTTPException for other potential errors, providing appropriate feedback to the user. Similar error handling is implemented for other moderation commands to ensure smooth operation and clear communication of any issues.

Created: | Last Updated:

Multipurpose Discord bot with a moderation feature to kick users from the server using the !kick command.

Here's a step-by-step guide on how to use the Multipurpose Discord Bot template:

Introduction

This template provides a multipurpose Discord bot with moderation features. The bot can kick, ban, timeout, and warn users, as well as log moderation cases and display them. It also includes commands to make the bot say messages and send direct messages to users.

Getting Started

  1. Click "Start with this Template" to begin using this template in the Lazy Builder interface.

Initial Setup

  1. Set up the required environment secret:
  2. In the Lazy Builder, go to the Environment Secrets tab.
  3. Add a new secret with the key BOT_TOKEN.
  4. For the value, you need to obtain a Discord bot token:

    • Go to the Discord Developer Portal.
    • Create a new application or select an existing one.
    • Navigate to the "Bot" section and click "Add Bot" if you haven't already.
    • Under the bot's token, click "Copy" to copy the token.
    • Paste this token as the value for the BOT_TOKEN secret in Lazy Builder.
  5. Configure bot permissions:

  6. In the Discord Developer Portal, go to the "OAuth2" section.
  7. Under "Scopes", select "bot".
  8. Under "Bot Permissions", select the following:
    • Kick Members
    • Ban Members
    • Moderate Members
    • Send Messages
    • Use Slash Commands
  9. Copy the generated OAuth2 URL and use it to invite the bot to your Discord server.

Test the Bot

  1. Click the "Test" button in the Lazy Builder to deploy and start the bot.

Using the Bot

  1. Once the bot is running, you can use the following slash commands in your Discord server:

  2. /kick: Kick a member from the server

  3. /ban: Ban a member from the server
  4. /timeout: Timeout a member for a specified duration
  5. /warn: Warn a member
  6. /modcase: View moderation cases for a user
  7. /say: Make the bot say something
  8. /dm: Send a direct message to a user

Example usage: /kick @username Spamming in chat /ban @username Repeated violations /timeout @username 60 Inappropriate behavior /warn @username Please follow the server rules /modcase @username /say Hello, everyone! /dm @username Please check the server rules

  1. The bot will automatically log moderation actions to a SQLite database, which can be viewed using the /modcase command.

By following these steps, you'll have a functional multipurpose Discord bot with moderation features running in your server. Remember to use these moderation tools responsibly and in accordance with your server's rules and Discord's Terms of Service.



Here are 5 key business benefits for this Discord bot template:

Template Benefits

  1. Enhanced Server Moderation: The bot provides powerful moderation tools like kick, ban, timeout, and warn commands, allowing server administrators to maintain order and enforce rules efficiently.

  2. Detailed Moderation Logging: With its SQLite database integration, the bot logs all moderation actions, enabling admins to track user behavior patterns and maintain a comprehensive moderation history.

  3. Improved Communication: The 'say' and 'dm' commands facilitate better communication between moderators and users, allowing for announcements and private messages directly through the bot.

  4. Customizable Command Prefix: The bot uses slash commands, which are more user-friendly and reduce command conflicts with other bots, enhancing the overall user experience.

  5. Scalability and Extensibility: Built with Discord.py, this template provides a solid foundation that can be easily expanded to include additional features like role management, auto-moderation, or integration with external services.

Technologies

Discord Automation & Bots Discord Automation & Bots

Similar templates

We found some blogs you might like...