Gunmen have attacked a village in western Niger, killing at least 31 people and seriously injuring four others.