How to find the user depends on how you are getting the username in the first place.
For example, if you are doing it based on a message the banned user sent, Message.from_user
exposes the User
object of the sender, giving you access to the user id.
Alternatively, if you have a command like /ban @username
with the user tagged, the Message.entities
returns you a list of MessageEntity
s, which you can iterate through to find the tagged user's entity. See the documentation for Message.entities and MessageEntity.