Skip to content

Instantly share code, notes, and snippets.

@m3gapi
Forked from doge/leave.py
Last active July 1, 2024 10:36
Show Gist options
  • Save m3gapi/1a88e535bf4e0bce77b539a1b18c5598 to your computer and use it in GitHub Desktop.
Save m3gapi/1a88e535bf4e0bce77b539a1b18c5598 to your computer and use it in GitHub Desktop.
Mass Leave Discord Servers
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True # Allow your bot to read message content
intents.members = True # Allow your bot to see members in servers
client = discord.Client()
token = "your-client-token"
whitelist = [
# discord guild ids you don't want to leave
123456789012345678,
876543210987654321
]
@client.event
async def on_ready():
for guild in client.guilds:
try:
if guild.id not in whitelist:
server = client.get_guild(guild.id)
await server.leave()
except Exception as e:
print(e)
client.run(token, bot=False)
@m3gapi
Copy link
Author

m3gapi commented Jul 1, 2024

It worked for me on replit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment