rlp81
rlp81

Reputation: 7

discord bot AFK command

So I'm trying to make an AFK command but the nickname doesn't want to work. Here's my code.

@Client.command(name="AFK")
async def afk(context):
    name = context.author.display_name
    author = context.author
    guild = context.guild
    AFKrole = discord.utils.get(guild.roles, name="AFK")
    if not AFKrole:
        AFKrole = await guild.create_role(name="AFK")
    await context.member.edit(nick=f"[AFK]{name}")
    await author.add_roles(AFKrole)
    await context.send(f"I have added {author} to AFK.")

Upvotes: 0

Views: 332

Answers (1)

sldless
sldless

Reputation: 101

Try:

await ctx.author.edit(nick=f'[AFK]{name}') #ctx = context, but you can change it to context

or try giving it the manage_nicknames permission.
click here <- The docs on the edit function

Upvotes: 1

Related Questions