set_chat_username()#

Client.set_chat_username()#

Set a channel or a supergroup username.

To set your own username (for users only, not bots) you can use set_username().

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

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

Returns:

bool – True on success.

Raises:

ValueError – In case a chat id belongs to a user or chat.

Example

await app.set_chat_username(chat_id, "new_username")