What is the best way to extract a tagged user's ID in my Discord bot?

I’m implementing profile cards in my Discord bot, but I’ve encountered a challenge. When a user sends !profile @user, I’m unsure how to extract the user’s ID from @user so that the bot can retrieve the corresponding profile card.

Currently, I take the message’s content and discard the first nine characters (the command !profile). However, the remaining string returns the user ID in the format <@289583108183948460>, rather than getting the user’s unique discriminator. I’ve attempted to use re.sub to eliminate unwanted characters such as @ and <>, like this:

msg_content = str(message.content[9:])
cleaned_id = re.sub("[!@#$%^&*()[]{};:,./<>?\|`~-=_+]", " ", msg_content)
print(cleaned_id)

Unfortunately, I still see unwanted characters in the output, and I only want the numeric ID for easy database queries. I’m confident there’s a more efficient way to achieve this, but I’m at a loss.