'Client' object has no attribute 'UserDoesNotExistError'

code:

@bot.command()
@has_permissions(manage_guild=True)
async def setrank(ctx, username, rank: int):
    if rank not in [15, 16]:
        await ctx.send("Rank must be either 15 or 16.")
        return

    try:
        group = await roblox.get_group(33909219)
        member = await group.get_member_by_username(username)
        
        if member is None:
            await ctx.send("The user was not found in the group.")
            return
        
        current_rank = await member.get_role()
        if current_rank in [15, 16]:
            await ctx.send(f"User already has a rank {current_rank}.")
        else:
            await member.setrole(rank)
            await ctx.send("Gived.")
    
    except roblox.UserDoesNotExistError:
        await ctx.send("User not found in group.")
    
    except Exception as e:
        await ctx.send(f"An error has occurred: {e}")

don’t close the post
used the command: !setrank luddeffs0 15
player profile: Vladimir_Luciver - Roblox

Read the error, what does it say?

object has no attribute ‘UserDoesNotExistError’
but I don’t understand exactly what to change, I’m trying to use a script from devforum Create Discord-to-Roblox bots with ro.py! - Community Tutorials - Developer Forum | Roblox

Do you know how to program in Python?

weak, I’m a beginner

Perhaps take a look at this:

https://ro.py.jmk.gg/dev/tutorials/error-handling/

Also perhaps learning Python may be a good starting point, also googling what your error means is a good start.

I don’t quite understand the error, and using the documentation

Basically you have your object which is a client, and you say roblox.UserDoesNotExistError, roblox does not have an attribute roblox.UserDoesNotExistError. Instead you should import UserNotFound in your code:

from roblox.utilities.exceptions import UserNotFound

try:
    user = await client.get_user_by_username("InvalidUsername!!!")
except UserNotFound:
    print("Invalid username!")

Thank you, now it just says: An error has occurred:

That seems to have worked - I’ll go ahead and mark Noah’s post as the solution.

no, its dont work br…

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.