Skip to main content

channels.checkUsername

Check if a username is free and can be assigned to a channel/supergroup

func (c *Client) ChannelsCheckUsername(ctx context.Context, request *ChannelsCheckUsernameRequest) (bool, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.ChannelsCheckUsername(ctx, &tg.ChannelsCheckUsernameRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // bool
return nil
})

Parameters

NameTypeRequiredDescription
ChannelInputChannelClassyesThe channel/supergroup that will assigned the specified username
UsernamestringyesThe username to check

Returns

bool

Possible errors

CodeTypeDescription
400CHANNELS_ADMIN_PUBLIC_TOO_MUCHYou're admin of too many public channels, make some channels private to change the username of this channel.
400CHANNEL_INVALIDThe provided channel is invalid.
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400CHAT_ID_INVALIDThe provided chat id is invalid.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.
400USERNAME_INVALIDThe provided username is not valid.
400USERNAME_OCCUPIEDThe provided username is already occupied.
400USERNAME_PURCHASE_AVAILABLEThe specified username can be purchased on https://fragment.com.

References