Skip to content

Instantly share code, notes, and snippets.

@vivekjoshy
Last active July 14, 2026 00:42
Show Gist options
  • Select an option

  • Save vivekjoshy/dda3dc99c09e2c6430b09c9ae23b646b to your computer and use it in GitHub Desktop.

Select an option

Save vivekjoshy/dda3dc99c09e2c6430b09c9ae23b646b to your computer and use it in GitHub Desktop.
Script to ban members of a discord servers.
#!/usr/bin/python
"""
# WARNING!
# DO not use this script for malicious purposes!
# Author: daegontaven - taven#0001
# License: Public Domain
# README
# I have resigned from using discord indefinitely to pursue schoolwork.
# As such I will not be maintaining this script anymore.
# How to Install
1 - Download Python 3.7 or 3.6 : https://www.python.org/downloads/
2 - Run this command : python3 -m pip install discord.py
3 - Run this command : python3 discord-ban-bot.py
4 - Invite bot to the servers you want to ban members from.
5 - Wait until banning is done. Don't close the terminal. This may take a while.
"""
import discord
TOKEN = "" # Put your Bot token here
SKIP_BOTS = False
client = discord.Client()
@client.event
async def on_ready():
print('Logged in!')
for member in client.get_all_members():
if member.bot and SKIP_BOTS:
continue
await member.ban(reason="Banned by BanBot", delete_message_days=7)
print(f"Banned {member.display_name}!")
print("Banning is complete!")
client.run(TOKEN)
@NotEG2

NotEG2 commented May 20, 2021

Copy link
Copy Markdown

It isn't working for me,
" Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions "
My bot has admin perms.

@lukadd16

Copy link
Copy Markdown

It isn't working for me,
" Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions "
My bot has admin perms.

@NotEG2 Read one of my previous comments on this matter
https://gist.github.com/daegontaven/dda3dc99c09e2c6430b09c9ae23b646b#gistcomment-3624418

@Tecno19

Tecno19 commented Jun 23, 2021

Copy link
Copy Markdown

what is the command to ban .ban or what

ghost commented Jul 10, 2021

Copy link
Copy Markdown

Made a working verison in fork

ghost commented Jul 10, 2021

Copy link
Copy Markdown

Hello bro so i am getting thiss error when i am runing your script
Screenshot_2021-03-02-00-58-56-43

The reason that is its not finding any members is cause the bot has 0 intents to fix this problem enabke the members intent and it should work

ghost commented Sep 27, 2021

Copy link
Copy Markdown

I followed all the steps, but I keep getting this error
C:\Users\Faisal\Desktop>discord-ban-bot.py
Logged in!
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Faisal\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Faisal\Desktop\discord-ban-bot.py", line 33, in on_ready
await member.ban(reason="Banned by BanBot", delete_message_days=7)
File "C:\Users\Faisal\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\member.py", line 498, in ban
await self.guild.ban(self, **kwargs)
File "C:\Users\Faisal\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\guild.py", line 1878, in ban
await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
File "C:\Users\Faisal\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\http.py", line 241, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

I even changed the role for the bot and gave it all permission.. but nothing changed

Same for me. Someone please help.

@joelovesraphinha

Copy link
Copy Markdown

image

what should I do now

ghost commented Nov 23, 2021 via email

Copy link
Copy Markdown

@MVPHANIFA

Copy link
Copy Markdown

i need help im a hugggeeee noob actually not even that.pls friend me and hopefully u are willing to teach me.ABU#8804

@wereyupo

Copy link
Copy Markdown

I keep getting this
image

@wereyupo

Copy link
Copy Markdown

how do i fix it?

@junesties

Copy link
Copy Markdown

You guys should seriously start with the basics instead of just copy& paste any code you see into your bot. And seriously learn syntax πŸ˜…

@itsangelo92

itsangelo92 commented Mar 13, 2022

Copy link
Copy Markdown

Hey everyone, hope you're all fine, first of all you must activate this things in discord for developers (in your bot section):
image

Then paste this code to your bot:

import discord

intents = discord.Intents.all()
client = discord.Client(intents=intents)

TOKEN = ""      # Put your Bot token here
SKIP_BOTS = False

@client.event
async def on_ready():
    for member in client.get_all_members():
        try:
            if(member.bot and SKIP_BOTS):
                continue

            await member.ban(reason="message")
        except:
            print("I can't ban this user due to permissions issues: " + member.display_name)

client.run(TOKEN)

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