I've been working really hard with a massban command but it doesn't work. Here is the code. Basically it doesn't do anything and I get no error in console.
@bot.command()
async def massban(ctx, user: discord.User ):
for user in ctx.guild.members:
try:
await user.ban(user)
except:
pass
If you want you can ban all members that your bot can see.
@bot.command()
async def massban(ctx):
for member in bot.get_all_members():
await member.ban()
It seems like the problem is here:
await user.ban(user)
You do not need to mention the user
in the brackets. It is enough if you remove the "argument":
@bot.command()
async def massban(ctx):
for user in ctx.guild.members:
try:
await user.ban()
except:
pass
This command bans all the user from your guild.
so, you need a guild your bot can see.
@bot.command()
async def massban(ctx):
await ctx.message.delete()
guild = ctx.guild
for user in ctx.guild.members:
try:
await user.ban()
except:
pass
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.