#im getting a weird class error

1 messages · Page 1 of 1 (latest)

raw parrot
#

idk how to explain it....

this code:

@bot.slash_command(name = 'unban', description = 'unban any banned members')
@commands.has_permissions(ban_members = True)
async def unban(ctx, user: discord.member):
    banned_users = await ctx.guild.bans()
    user_name, user_discriminator = user.split('#')

    for ban_entry in banned_users:
        user = ban_entry.user
        if (user.name, user.discriminator) == (user_name, user_discriminator):
            await ctx.guild.unban(user)
            await ctx.send(f"{user} has been unbanned.")
            await user.send("You have been unbanned")

@unban.error
async def permserror(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        ctx.respond('Sorry! You dont have permission.')
``` its giving me this error:
```Exception has occurred: TypeError
issubclass() arg 1 must be a class
  File "C:\Users\Nico Spina\Downloads\32oz (discord bot)\bot.py", line 51, in <module>
    @bot.slash_command(name = 'unban', description = 'unban any banned members')
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class```
proud tendon
#

just simply guild.unban

raw parrot
#

im new

proud tendon
#

anyways we'll get to that later

#

can you show your pip list

raw parrot
#

it was working fine until i decided to make it dm the user

proud tendon
#

hmm

raw parrot
#

umm of just the unban part of it it should be

#

i can send all my code if you want

proud tendon
#

but i wanted full error

raw parrot
#

yeah it is

#

the full error

proud tendon
#

hmm weird

raw parrot
proud tendon
raw parrot
#

yes

#

it was originally ctx, discord.member, i changed it to ctx, user: discord.member than i changed the member in that command to user

#

could be something with that

proud tendon
#

discord.Member with M uppercase

#

ctx, user: discord.Member

#

small things you dont notice 😂

raw parrot
#

yup

#

that fixed t

#

🤣

proud tendon
#

haha

raw parrot
#

could i possibld do guild.kick? becuase im having trouble with kick command

proud tendon
# proud tendon ok so about this

you can simply do await guild.unban(user). if user is not banned, it will raise error. you can handle that error. no need to fetch bans and iterate through them

raw parrot
#

@bot.slash_command(name = 'kick', description = 'kick a member')
@commands.has_permissions(kick_members = True)
async def kick(ctx, user:discord.Member, *, reason = None):
    if reason == None:
        reason = 'no reason'
    await discord.guild.kick(user, reason=reason)
    ctx.respond(f'{discord.Member} has been kicked')
    await user.send("You have been kicked")
@kick.error
async def permserror(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        ctx.respond('Sorry! You dont have permission.')``` is the code im experimenting with
#

to try and make a kick command

proud tendon
#

it would be ctx.guild, not discord.guild

raw parrot
#

i cant test it becuase i put the guild = discord.Guild in the kick(ctx) so it is now saying outdated and the guild input wont go away on the slash command

proud tendon
#

also, await ctx.respond

#

you dont seem to do it everywhere

raw parrot
#

i was doing it than i changed it trying to do mention but im lazy so im not changing it

cursive mothBOT
#

This thread was archived by the user that opened it.