Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import discord
- from discord.ext import commands
- from colorama import Fore, Style
- token = os.getenv("DISCORD_BOT_TOKEN") or input("Enter your bot token: ")
- server_id_env = os.getenv("DISCORD_SERVER_ID")
- try:
- server_id = int(server_id_env) if server_id_env else int(input("Enter your server ID: "))
- except ValueError:
- raise ValueError("Server ID must be a valid integer.")
- if not token or not server_id:
- raise ValueError("Bot token and server ID must be set as environment variables or provided manually.")
- intents = discord.Intents.all()
- intents.members = True
- bot = commands.Bot(command_prefix="!", intents=intents)
- @bot.event
- async def on_ready():
- print(f"Logged in as {bot.user}")
- banner = """
- ███╗ ██╗██╗ ██╗██╗ ██╗███████╗██████╗ ██╗███████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗ ██╗
- ████╗ ██║██║ ██║██║ ██╔╝██╔════╝██╔══██╗ ██║██╔════╝ ██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝
- ██╔██╗ ██║██║ ██║█████╔╝ █████╗ ██████╔╝ ██║███████╗ ██████╔╝█████╗ ███████║██║ ██║ ╚████╔╝
- ██║╚██╗██║██║ ██║██╔═██╗ ██╔══╝ ██╔══██╗ ██║╚════██║ ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ╚██╔╝
- ██║ ╚████║╚██████╔╝██║ ██╗███████╗██║ ██║ ██║███████║ ██║ ██║███████╗██║ ██║██████╔╝ ██║
- ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝
- ( Made by ryan <3 )
- Type !commands in any channel to list commands
- """
- print(Fore.BLUE + banner[:len(banner)//2] + Fore.MAGENTA + banner[len(banner)//2:])
- @bot.command()
- async def delete_all_channels(ctx):
- guild = bot.get_guild(server_id)
- if guild and ctx.guild.id == server_id:
- for channel in guild.channels:
- try:
- await channel.delete()
- print(f"Deleted channel: {channel.name}")
- except Exception as e:
- print(f"Failed to delete channel {channel.name}: {e}")
- else:
- await ctx.send("This command can only be used in the specified server.")
- @bot.command()
- async def create_channels(ctx, name: str, quantity: int):
- guild = bot.get_guild(server_id)
- if guild and ctx.guild.id == server_id:
- for i in range(quantity):
- try:
- await guild.create_text_channel(f"{name}-{i+1}")
- print(f"Created channel: {name}-{i+1}")
- except Exception as e:
- print(f"Failed to create channel {name}-{i+1}: {e}")
- else:
- await ctx.send("This command can only be used in the specified server.")
- @bot.command()
- async def ban_all_members(ctx):
- guild = bot.get_guild(server_id)
- if guild and ctx.guild.id == server_id:
- for member in guild.members:
- if member != ctx.author and not member.bot:
- try:
- await member.ban(reason="Mass ban command")
- print(f"Banned member: {member.name}")
- except Exception as e:
- print(f"Failed to ban {member.name}: {e}")
- else:
- await ctx.send("This command can only be used in the specified server.")
- @bot.command()
- async def dm_all_members(ctx, *, message: str):
- guild = bot.get_guild(server_id)
- if guild and ctx.guild.id == server_id:
- for member in guild.members:
- if not member.bot:
- try:
- await member.send(message)
- print(f"Sent DM to {member.name}")
- except Exception as e:
- print(f"Failed to send DM to {member.name}: {e}")
- else:
- await ctx.send("This command can only be used in the specified server.")
- @bot.command()
- async def purge(ctx, limit: int):
- if ctx.guild.id == server_id:
- try:
- await ctx.channel.purge(limit=limit)
- print(f"Purged {limit} messages in {ctx.channel.name}")
- except Exception as e:
- print(f"Failed to purge messages: {e}")
- else:
- await ctx.send("This command can only be used in the specified server.")
- @bot.command(name="commands")
- async def list_commands(ctx):
- commands_list = [
- "```",
- "┌─┐┌─┐┬─┐┌┬┐ ┌─┐┌┬┐┌─┐┌─┐┬ ┬┌─┐┬─┐",
- "│ │ │├┬┘ ││ └─┐│││├─┤└─┐├─┤├┤ ├┬┘",
- "└─┘└─┘┴└──┴┘ └─┘┴ ┴┴ ┴└─┘┴ ┴└─┘┴└─",
- "```",
- "!delete_all_channels - Deletes all channels in the server.",
- "!create_channels <name> <quantity> - Creates a specified number of channels with a given name.",
- "!ban_all_members - Bans all members except the bot and the command issuer.",
- "!dm_all_members <message> - Sends a direct message to all members.",
- "!purge <limit> - Deletes the specified number of messages in the channel.",
- "!commands - Lists all available commands.",
- "!buy_source - Provides a link to purchase the source code.",
- "!list_members - Lists all members in the server with their details."
- ]
- await ctx.send("\n".join(commands_list))
- @bot.command()
- async def buy_source(ctx):
- await ctx.send("You can purchase the source code here: https://dream-services.mysellix.io/")
- @bot.command()
- async def list_members(ctx):
- guild = bot.get_guild(server_id)
- if guild and ctx.guild.id == server_id:
- members_info = [
- "```Members in the server:\n"
- ]
- for member in guild.members:
- members_info.append(
- f"Username: {member.name}#{member.discriminator}\n"
- f"User ID: {member.id}\n"
- f"Avatar URL: {member.avatar.url if member.avatar else 'No Avatar'}\n"
- f"Joined: {member.joined_at}\n\n"
- )
- members_info.append("```")
- await ctx.send("".join(members_info))
- else:
- await ctx.send("This command can only be used in the specified server.")
- # Run the bot
- bot.run(token)
Advertisement
Add Comment
Please, Sign In to add comment