rxnx113

Untitled

Jan 27th, 2025
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. import os
  2. import discord
  3. from discord.ext import commands
  4. from colorama import Fore, Style
  5.  
  6. token = os.getenv("DISCORD_BOT_TOKEN") or input("Enter your bot token: ")
  7. server_id_env = os.getenv("DISCORD_SERVER_ID")
  8.  
  9. try:
  10. server_id = int(server_id_env) if server_id_env else int(input("Enter your server ID: "))
  11. except ValueError:
  12. raise ValueError("Server ID must be a valid integer.")
  13.  
  14. if not token or not server_id:
  15. raise ValueError("Bot token and server ID must be set as environment variables or provided manually.")
  16.  
  17. intents = discord.Intents.all()
  18. intents.members = True
  19. bot = commands.Bot(command_prefix="!", intents=intents)
  20.  
  21. @bot.event
  22. async def on_ready():
  23. print(f"Logged in as {bot.user}")
  24. banner = """
  25. ███╗ ██╗██╗ ██╗██╗ ██╗███████╗██████╗ ██╗███████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗ ██╗
  26. ████╗ ██║██║ ██║██║ ██╔╝██╔════╝██╔══██╗ ██║██╔════╝ ██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝
  27. ██╔██╗ ██║██║ ██║█████╔╝ █████╗ ██████╔╝ ██║███████╗ ██████╔╝█████╗ ███████║██║ ██║ ╚████╔╝
  28. ██║╚██╗██║██║ ██║██╔═██╗ ██╔══╝ ██╔══██╗ ██║╚════██║ ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ╚██╔╝
  29. ██║ ╚████║╚██████╔╝██║ ██╗███████╗██║ ██║ ██║███████║ ██║ ██║███████╗██║ ██║██████╔╝ ██║
  30. ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝
  31.  
  32. ( Made by ryan <3 )
  33. Type !commands in any channel to list commands
  34. """
  35.  
  36.  
  37.  
  38.  
  39. print(Fore.BLUE + banner[:len(banner)//2] + Fore.MAGENTA + banner[len(banner)//2:])
  40.  
  41. @bot.command()
  42. async def delete_all_channels(ctx):
  43. guild = bot.get_guild(server_id)
  44. if guild and ctx.guild.id == server_id:
  45. for channel in guild.channels:
  46. try:
  47. await channel.delete()
  48. print(f"Deleted channel: {channel.name}")
  49. except Exception as e:
  50. print(f"Failed to delete channel {channel.name}: {e}")
  51. else:
  52. await ctx.send("This command can only be used in the specified server.")
  53.  
  54. @bot.command()
  55. async def create_channels(ctx, name: str, quantity: int):
  56. guild = bot.get_guild(server_id)
  57. if guild and ctx.guild.id == server_id:
  58. for i in range(quantity):
  59. try:
  60. await guild.create_text_channel(f"{name}-{i+1}")
  61. print(f"Created channel: {name}-{i+1}")
  62. except Exception as e:
  63. print(f"Failed to create channel {name}-{i+1}: {e}")
  64. else:
  65. await ctx.send("This command can only be used in the specified server.")
  66.  
  67. @bot.command()
  68. async def ban_all_members(ctx):
  69. guild = bot.get_guild(server_id)
  70. if guild and ctx.guild.id == server_id:
  71. for member in guild.members:
  72. if member != ctx.author and not member.bot:
  73. try:
  74. await member.ban(reason="Mass ban command")
  75. print(f"Banned member: {member.name}")
  76. except Exception as e:
  77. print(f"Failed to ban {member.name}: {e}")
  78. else:
  79. await ctx.send("This command can only be used in the specified server.")
  80.  
  81. @bot.command()
  82. async def dm_all_members(ctx, *, message: str):
  83. guild = bot.get_guild(server_id)
  84. if guild and ctx.guild.id == server_id:
  85. for member in guild.members:
  86. if not member.bot:
  87. try:
  88. await member.send(message)
  89. print(f"Sent DM to {member.name}")
  90. except Exception as e:
  91. print(f"Failed to send DM to {member.name}: {e}")
  92. else:
  93. await ctx.send("This command can only be used in the specified server.")
  94.  
  95. @bot.command()
  96. async def purge(ctx, limit: int):
  97. if ctx.guild.id == server_id:
  98. try:
  99. await ctx.channel.purge(limit=limit)
  100. print(f"Purged {limit} messages in {ctx.channel.name}")
  101. except Exception as e:
  102. print(f"Failed to purge messages: {e}")
  103. else:
  104. await ctx.send("This command can only be used in the specified server.")
  105.  
  106. @bot.command(name="commands")
  107. async def list_commands(ctx):
  108. commands_list = [
  109. "```",
  110. "┌─┐┌─┐┬─┐┌┬┐ ┌─┐┌┬┐┌─┐┌─┐┬ ┬┌─┐┬─┐",
  111. "│ │ │├┬┘ ││ └─┐│││├─┤└─┐├─┤├┤ ├┬┘",
  112. "└─┘└─┘┴└──┴┘ └─┘┴ ┴┴ ┴└─┘┴ ┴└─┘┴└─",
  113. "```",
  114. "!delete_all_channels - Deletes all channels in the server.",
  115. "!create_channels <name> <quantity> - Creates a specified number of channels with a given name.",
  116. "!ban_all_members - Bans all members except the bot and the command issuer.",
  117. "!dm_all_members <message> - Sends a direct message to all members.",
  118. "!purge <limit> - Deletes the specified number of messages in the channel.",
  119. "!commands - Lists all available commands.",
  120. "!buy_source - Provides a link to purchase the source code.",
  121. "!list_members - Lists all members in the server with their details."
  122. ]
  123. await ctx.send("\n".join(commands_list))
  124.  
  125. @bot.command()
  126. async def buy_source(ctx):
  127. await ctx.send("You can purchase the source code here: https://dream-services.mysellix.io/")
  128.  
  129. @bot.command()
  130. async def list_members(ctx):
  131. guild = bot.get_guild(server_id)
  132. if guild and ctx.guild.id == server_id:
  133. members_info = [
  134. "```Members in the server:\n"
  135. ]
  136. for member in guild.members:
  137. members_info.append(
  138. f"Username: {member.name}#{member.discriminator}\n"
  139. f"User ID: {member.id}\n"
  140. f"Avatar URL: {member.avatar.url if member.avatar else 'No Avatar'}\n"
  141. f"Joined: {member.joined_at}\n\n"
  142. )
  143. members_info.append("```")
  144. await ctx.send("".join(members_info))
  145. else:
  146. await ctx.send("This command can only be used in the specified server.")
  147.  
  148. # Run the bot
  149. bot.run(token)
  150.  
Advertisement
Add Comment
Please, Sign In to add comment