Last active
May 6, 2025 11:08
-
-
Save doge/a4871f8371098ba4a44f2eb99b79e12a to your computer and use it in GitHub Desktop.
Mass Leave Discord Servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
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) |
works with very minor modifications:
import discord
client = discord.Client(intents=discord.Intents.none())
token = input("bot token:")
whitelist = [
# discord guild ids you don't want to leave
876543210987654321
]
@client.event
async def on_ready():
for guild in client.guilds:
print(guild.id)
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)
Wow this was a long time ago old times bruh
doesnt work anymore. @ryleu your code also doesn't work.
doesnt work anymore. @ryleu your code also doesn't work.
https://discordpy.readthedocs.io/en/stable/api.html?highlight=guild%20leave#discord.Guild.leave rtfm
For folks coming from Google, I made an updated version of the script that works: https://gist.github.com/SkyfallWasTaken/f35a11cd8c49efaa375b3b30b856c1a4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is outdated, doesn't work.