1

I was making a discord bot unban command in cog file but when I go to discord and try to unban it says

Command raised an exception: TypeError: unban() takes 1 positional argument but 2 were given

Here's the full code

@commands.command(aliases=['ub'])
@commands.has_permissions(ban_members=True)
async def unban(ctx, *, member):
    banned_users = await ctx.guild.bans()
    member_name, member_discriminator = member.split('#')

    for banned_entry in banned_users:
        user = banned_entry.user

        if (user.name, user.discriminator) == (member_name, member_discriminator):
            
            await ctx.guild.unban(user)
            await ctx.send(f'Unbanned {user.mention}')
            try:
                await member.send("You have been unbanned from Scar Community Server   https://discord.gg/bXGTk9x7 ")
            except:
                await ctx.send("Cannot DM them!")
            return

1 Answers1

0

Any method of a class requires self as the first parameter.

@commands.command(aliases=['ub'])
@commands.has_permissions(ban_members=True)
async def unban(self, ctx, *, member):
    # ...
Makonede
  • 442
  • 1
  • 6
  • 13