Checking if the message.author has a certain role

I’m trying to make a command that can only be used by people with a certain role. Currently I’m using:

if discord.utils.get(message.author.roles, name="Admin").name == "Admin":
    #do stuff here

it works, but if the user doesn’t have that role a

AttributeError: ‘NoneType’ object has no attribute ‘name’

error is thrown. Is there any native discord.py function that could be used?

I’m not keen on trying to catch the problem with exceptions

has_roles() no longer seems to exist

Answer

The error message is very helpful here. Apparently get sometimes returns None.

role = discord.utils.get(message.author.roles, name="Admin")
if role is not None and role.name == "Admin":
    #do stuff here