# If you need this in a bot command
@discord.ext.commands.command()
async def online(ctx):
guild_id = ctx.guild.id # the guild id where the command has been called
role = discord.utils.get(bot.get_guild(guild_id).roles, id ="""The Id of the role you search""")
await member.add_roles(role) # The role gets added to a given Member