'how to change the code to send a dm over role id (python 3.6)

I want to change the lines below, to contact all member with a specific role at the same time. It works with the user id, but it would be more efficient, if it works with any role id.

Is there any chance? I´m stuck :D

@bot.command ()
async def inac(ctx, user_id=None):
    if user_id != None:
         try:
            target = await bot.fetch_user(user_id)
            embed = discord.Embed(title="warning", description="the text in this embed", color=0xff0000)
            embed.add_field(name="reason", value="inactivity", inline=False)
            embed.set_footer(text="AutoMessage")
            await target.send(embed=embed)
            await ctx.channel.send("succesfull:")
         except:
            await ctx.channel.send("I can´t contact the member!")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source