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
Usable by Users Botsset_chat_username()
.- 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")