#There is something wrong with my code but i dont know what it is
1 messages · Page 1 of 1 (latest)
@bot.command()
async def verify(ctx, username):
user = await roblox.get_user_by_username(username)
member = ctx.message.author
role = get(member.server.roles, name="Verified")
embed = Embed(
title="Verification"
)
embed.add_field(
name="You are now verified as:",
value="`" + user.name + "`"
)
await ctx.send(embed=embed)
await bot.add_roles(member, role)
what is wrong with my code?
this is my error:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 61, in verify
role = get(member.server.roles, name="Verified")
AttributeError: 'Member' object has no attribute 'server'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'server'
how do i fix it
And I'd recommend checking out the docs ^
'Member' object has no attribute 'server'
do i use guild?
instead of server?
i now get this error
when i fixed everything
NotFound: 404 Not Found (error code: 10011): Unknown Role
the role is correct
there is a Verified role
on the server
but it says its unknown
@vocal carbon
my code:
@bot.command()
async def verify(ctx, username):
user = await roblox.get_user_by_username(username)
member = ctx.message.author
role = get(member.guild.roles, name="Verified")
embed = Embed(
title="Verification"
)
embed.add_field(
name="You are now verified as:",
value="`" + user.name + "`"
)
await ctx.send(embed=embed)
await member.add_roles(member, role)
@vocal carbon