set_username()#
- Client.set_username()#
Changes the editable username of the current user.
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. The username can’t be completely removed if there is another active or disabled username.- Returns:
bool
– True on success.
Example
await app.set_username("new_username")