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
  • 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.py
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

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