help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
discord-ai-bot
/
cogs
RSK World
discord-ai-bot
Discord AI Bot - Python + discord.py + OpenAI API + AI Bot + Server Management + Moderation
cogs
  • __pycache__
  • __init__.py153 B
  • ai.py3.8 KB
  • automation.py2.2 KB
  • logging.py3.1 KB
  • management.py1.9 KB
  • moderation.py3.4 KB
automation.pyREADME.md
cogs/automation.py
Raw Download
Find: Go to:
"""
Discord AI Bot - Automation Features
Author: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
"""

import discord
from discord.ext import commands
from collections import defaultdict
import time

class Automation(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.last_messages = defaultdict(list)
        self.spam_threshold = 3
        self.spam_interval = 5

    @commands.Cog.listener()
    async def on_member_join(self, member):
        try:
            channel = member.guild.system_channel or discord.utils.get(member.guild.text_channels, name="general")
            if channel:
                embed = discord.Embed(
                    title=f"Welcome to {member.guild.name}!",
                    description=f"Hello {member.mention}, we're glad to have you here! Powered by RSK World AI.",
                    color=discord.Color.purple()
                )
                embed.set_thumbnail(url=member.display_avatar.url)
                await channel.send(embed=embed)
        except discord.Forbidden:
            pass  # Bot doesn't have permission to send messages
        except Exception:
            pass  # Silently fail to avoid spam

    @commands.Cog.listener()
    async def on_message(self, message):
        if message.author.bot or not message.guild:
            return

        user_id = message.author.id
        current_time = time.time()
        self.last_messages[user_id] = [m for m in self.last_messages[user_id] if current_time - m[0] < self.spam_interval]
        duplicates = [m for m in self.last_messages[user_id] if m[1] == message.content]
        
        if len(self.last_messages[user_id]) >= self.spam_threshold or len(duplicates) >= 2:
            try:
                await message.delete()
                await message.channel.send(f"{message.author.mention}, please slow down! Anti-spam active.", delete_after=5)
            except discord.Forbidden:
                pass
        else:
            self.last_messages[user_id].append((current_time, message.content))

async def setup(bot):
    await bot.add_cog(Automation(bot))
60 lines•2.2 KB
python
README.md
Raw Download

README.md

# Discord AI Bot
A comprehensive Discord bot project integrating AI capabilities, server management, and moderation tools.

**Author:** RSK World | **Website:** [rskworld.in](https://rskworld.in) | **Year:** 2026

## 🚀 Features
- **AI-Powered Responses:** Integrated OpenAI GPT models with conversation memory.
- **Logging System:** Tracks message deletions and member events.
- **Automation:** Automated welcome messages and anti-spam protection.
- **Server Management:** Tools for managing server information and roles.
- **Moderation Tools:** Kick, ban, and message clearing commands.
- **Modular Architecture:** Built using the `discord.py` Cogs framework.

## 🛠️ Technologies
- **Python:** The core programming language.
- **discord.py:** Library for Discord API.
- **OpenAI API:** For AI-driven capabilities.
- **HTML/CSS:** For the custom landing page.

## 📦 Installation
1. `pip install -r requirements.txt`
2. Create a `.env` file in the project root with the following variables:
```
DISCORD_TOKEN=your_discord_bot_token_here
OPENAI_API_KEY=your_openai_api_key_here
LOG_CHANNEL_ID=optional_log_channel_id
```
3. `python bot.py`

## 🔧 Commands
- `!ask <question>`: Get an AI-powered answer.
- `!clear_memory`: Reset AI history.
- `!kick`, `!ban`, `!clear`: Moderation tools.
- `!serverinfo`, `!roleadd`: Management tools.

---
© 2026 RSK World. All Rights Reserved.
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer