Skip to content

Instantly share code, notes, and snippets.

@doge
Last active May 6, 2025 11:08
Show Gist options
  • Save doge/a4871f8371098ba4a44f2eb99b79e12a to your computer and use it in GitHub Desktop.
Save doge/a4871f8371098ba4a44f2eb99b79e12a to your computer and use it in GitHub Desktop.
Mass Leave Discord Servers
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)
@Heyheyitskk26
Copy link

How do I import this code into discord?

@shaurya11123
Copy link

through repl.it

@COD1EINE
Copy link

through repl.it

can u help?

@doge
Copy link
Author

doge commented Aug 20, 2021

through repl.it

can u help?

you must have some knowledge of coding if you're on github. import the code into a site like repl.it and fill in the variables.

@COD1EINE
Copy link

through repl.it

can u help?

you must have some knowledge of coding if you're on github. import the code into a site like repl.it and fill in the variables.

k , thanks <3

@MatoWiz
Copy link

MatoWiz commented Apr 24, 2022

I did but won't work it say something about import discord then something with home with an error

@doge
Copy link
Author

doge commented Apr 24, 2022

I did but won't work it say something about import discord then something with home with an error

You need the discord module installed on your computer.

@Cyber-Shinigami
Copy link

This works Thank you

@Cyber-Shinigami
Copy link

I think you should make a do's and don't file thingy where you should explain how using repl can be unsafe so better use you're own pc and stuff or if you still wanna use repl after use it's better to change password and enable 2fa for a while

@chrstnglmtc
Copy link

hi! i cloned your clone and made an easy to use version using google colab, i hope you don't mind. https://colab.research.google.com/gist/chrstnglmtc/2517392541515f079b757c64ec4980fe/discordleave.ipynb

@Locksdsc
Copy link

Locksdsc commented May 8, 2022

this one is so easy i don't understand how u guys struggle with 24 lines

@Locksdsc
Copy link

Locksdsc commented May 8, 2022

I think you should make a do's and don't file thingy where you should explain how using repl can be unsafe so better use you're own pc and stuff or if you still wanna use repl after use it's better to change password and enable 2fa for a while

you can use env in replit it's now secure

@Bennet12
Copy link

Bennet12 commented Jun 2, 2022

modified it a bit but worked like a charm

@vihaan8889
Copy link

discord.py migrated so you can no longer login to user accounts only bots

@biggermine
Copy link

bruh it says missing intents

@allixina
Copy link

allixina commented Jun 3, 2023

please update

@BMoradi1
Copy link

BMoradi1 commented Oct 3, 2023

Nice job. needed some janking but worked as it said on the tin. thanks.

@carterlasalle
Copy link

Nice job. needed some janking but worked as it said on the tin. thanks.

What did you change. Cant get it to work.

@Noveleader
Copy link

Nice job. needed some janking but worked as it said on the tin. thanks.

Can you please tell what worked for you ?

@koyomitan3
Copy link

Useless script, does not work please delete or close so we have less bait and outdated content on here!

@m3gapi
Copy link

m3gapi commented Jul 1, 2024

Does it still work or is it outdated?

@Noveleader
Copy link

It is outdated, doesn't work.

@ryleu
Copy link

ryleu commented Aug 3, 2024

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)

@Locksdsc
Copy link

Locksdsc commented Aug 3, 2024

Wow this was a long time ago old times bruh

@DolceJ0Lly
Copy link

doesnt work anymore. @ryleu your code also doesn't work.

@ryleu
Copy link

ryleu commented Nov 3, 2024

@SkyfallWasTaken
Copy link

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