Bot server
Managed by eitan339344566#0

About Bot server

import discord
from discord.ext import commands
import random
import asyncio

Setup Intents

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
print('------')

@bot.command()
@commands.has_permissions(manage_roles=True)
async def create_roles(ctx, amount: int, *, role_name: str):
"""
Creates multiple roles at once.
Usage: !create_roles 10 Moderator
"""
if amount > 200:
return await ctx.send("Error: Discord limit is 250 roles per server. Try a smaller number.")

await ctx.send(f"Starting to create {amount} roles named '{role_name}'...")

for i in range(1, amount + 1):
    try:
        # Generate a random color for each role
        random_color = discord.Color(random.randint(0x000000, 0xFFFFFF))

        # Create the role
        await ctx.guild.create_role(
            name=f"{role_name} {i}",
            color=random_color,
            reason="Bulk role creation script"
        )

        # Avoid Discord Rate Limits (sleep for 0.5s every 5 roles)
        if i % 5 == 0:
            await asyncio.sleep(0.5)

    except discord.Forbidden:
        return await ctx.send("Error: I don't have 'Manage Roles' permission.")
    except discord.HTTPException as e:
        return await ctx.send(f"An error occurred: {e}")

await ctx.send(f"✅ Successfully created {amount} roles!")

Replace with your actual bot token

bot.run('YOUR_BOT_TOKEN_HERE')

Categories

Primary Language

657

Reviews

—
No verified reviews yet.

Reviews are from Discord users. We moderate them. Read the review rules before posting.

Write a review

No reviews yet.

Server Analytics Published

Listing updated

50 Total Members
40 Online Members
Live activity
— Last updated
Estimated Active Staff
Professionally Managed
12 to 32
active moderators