set_username()

Client.set_username()

Set your own username.

This method only works for users, not bots. Bot usernames must be changed via Bot Support or by recreating them from scratch using BotFather. To set a channel or supergroup username you can use set_chat_username().

Usable by Users Bots
Parameters:

username (str | None) – Username to set. “” (empty string) or None to remove it.

Returns:

bool – True on success.

Example

await app.set_username("new_username")