Samuel Marks
Samuel Marks

Reputation: 23

Change discord bot nickname (discord.py)

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

Upvotes: 2

Views: 2075

Answers (1)

Saddy
Saddy

Reputation: 1581

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.

Upvotes: 1

Related Questions