Change discord bot nickname (discord.py)

Viewed 1447

I have a simple issue that I'm yet to figure out, how can I change my bot's own nickname, because I want to display information instead of its nickname continuously.

tried this :

await bot.user.edit(username=price)

but this actually changes the username which is not allowed to be done multiple times.

async def status_update():
    while True:
        price = str(get_BTC_price(ws))
        await bot.user.edit(username=price)
        await asyncio.sleep (2)

@bot.event
async def on_ready():
    bot.loop.create_task(status_update())

Thanks

1 Answers

Nicknames are tied to Guild Members. In order to change your bot's nickname, you must

  1. Get the Guild Member object for your bot
  2. Use <Member>.edit(nick=nick)

Note that this will only change the nickname for one server. If you wanted it to be global you would have to loop through each guild and perform the operation (expensive). You may want to use the status box instead to convey this information.

Related